Wong Wengkeong
Wong Wengkeong

Reputation: 181

Getting intensity value for all pixels in an image

I have to create an algorithm to determine a dark "grayscale image" in matlab, so I have to collect all pixels' intensity value then evaluate that if 65% of all pixels in that particular image is lesser than 100 then it is dark.

the question is how to collect/get these value to create an algorithm like this?

Upvotes: 0

Views: 688

Answers (1)

LowPolyCorgi
LowPolyCorgi

Reputation: 5171

Assume your image is contained in an array Img (for instance, obtained with imread). Then:

% Define a threshold
th = 100; 

% Get the percentage of pixels below the threshold
p = nnz(Img<th)/numel(Img)*100;

% Decide what to do
if p<65
   ...
else
   ...
end

Hope this helps,

Upvotes: 3

Related Questions