Find black images in a file

2 views (last 30 days)
Sara Antonio
Sara Antonio on 18 Jan 2017
Commented: Sara Antonio on 18 Jan 2017
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!

Accepted Answer

Image Analyst
Image Analyst on 18 Jan 2017
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

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!