MATLAB: Find black images in a file

.jpgblack imageImage Processing Toolbox

Hello, So I have this file with jpg images (more than 5000 images), and some of them are completely black. I want to know how many black images I have in my file. I never worked with loading and doing loops with jpg images so I don't know how to generate the code. I was thinking on doing a loop where if the sum of the pixels would be zero (all pixels black), then it would be a black image, else a color image. The problem is that I don't know how to address the pixels in the image matrix.
Thanks in advance!

Best Answer

Yes, you can do that. First use one of the code samples in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Before the loop, put this:
count = 0;
In the middle of the loop, put this:
theSum = sum(sum(imageArray));
if theSum == 0
count = count + 1;
blackFiles{count} = fullFileName; % Or whatever
end