would probably be easier to extract the RGB values if you saved your pictures as bitmap format instead.
https://stackoverflow.com/questions/16784885/read-rgb-triplets-of-jpeg-files-in-c
"The JPEG file format does not store the rgb triplets directly but it uses some sort of image compression. The file actually contains blocks of 64 (if I remember correctly) pixels which are attributed with a cosine pattern defining the actual colors.
You really should use a library (libjpeg, imagemagick, gd, ... e.g., depending on your use case) to read and decode the files and generate the rgb triplets in memory."
but was not to find any such library for arduino boards...