1
votes

I have a couple hundred images like this one:

enter image description here

They are in a single folder and am trying to figure out a way in Matlab to automatically analyze each image's pixel values at point (700,755). I know how to do this one-at-a-time, as such:

rgb=impixel(p,700,755)

This returns the red-green-blue values at that particular point for the image. I'm very new to Matlab...what piece of code would analyze each image in the folder and save the RGB value on separate lines in a table/array?

Also, I have selected an area using the pixel region tool: '[696.463836477986 750.095011390851 19.9889937106933 13.3672527600921]' How do I analyze all the pixel values in that area and get the statistics (min, max, mean, etc.)...plus do that for all 200 images I have in the folder?

I appreciate the help! AP

1

1 Answers

2
votes

impixel can work for all the image as well:

impixel(I)

or for a specific (pixel) column and row:

impixel(I,c,r)

But you need first to read the image into a matrix. The imread function, returns all the RGB data of an image in an array:

A = imread(filename, fmt) 

it reads a grayscale or color image from the file specified by the string filename. A is an array containing the image data. If the file contains a 'grayscale' image, A is an 'M-by-N' array. If the file contains a 'truecolor' image, A is an 'M-by-N-by-3' array. (3: R-G-B)

To read a bunch of files in a folder do this:

files = dir('*.jpg');
for i=1:length(files)
    eval(['imread ' files(i).name]);
end

You can use imcrop function to crop the images you have:

using mouse:

I2 = imcrop(I)

or using dimensions:

I2 = imcrop(I,[75 68 130 112]);