Probability of gray level in an Image

5 views (last 30 days)
Hi all I want to know how to get the probability of one gray-level in my image samples.
I have 5 different images and I have computed the greylevel probability density function for each as the image histogram divided by the number of pixels in the image:
[pixelcount greylevel] = imhist(image); pdf = pixelcount/nPix;
So now I have the probability of all greyvalues to be found in each image, but what I really want to know is the propability to find a greyvalue in any image.
How can I combine the 5 different pdfs (one for each image) to have only one pdf.
Can I use the mean, max or min of the probability functions to combine them? If this is so, which one is better to use? Are there any other methods to combine the pdfs?
All my images have 256 graylevel. The images are not equally sized. I´m not sure if the pdfs can be described as a normal distribution.
Thanks

Accepted Answer

Michael Haderlein
Michael Haderlein on 22 Aug 2014
Edited: Michael Haderlein on 22 Aug 2014
Are all images equally sized? If so, if I didn't get you wrong, you can just use the mean of the 5 pdfs. Otherwise, you have to weight them according to the nPix of each image.
  3 Comments
Ahmet Cecen
Ahmet Cecen on 22 Aug 2014
Doing it this way, yes it would matter. You are more "confident" in the information in a bigger image because you have a bigger sample size, so you would want to weight the bigger image pdfs higher.
Fabian
Fabian on 22 Aug 2014
Ok so if I understand, if the image is big it would describe better the probability function than a small image. So bigger images should have more weight in the mean probability.
How should I weight the probability by its size? Should I give the bigger image a weight 1 and then go down?
Thanks

Sign in to comment.

More Answers (1)

Ahmet Cecen
Ahmet Cecen on 22 Aug 2014
Edited: Ahmet Cecen on 22 Aug 2014
npx=0;
count=0;
for i = 1:5
[pixelcount greylevel] = imhist(image(i));
count=count+pixelcount;
npx=npx+numel(image(i));
end
CombinedPdf=count/npx;
  3 Comments
Ahmet Cecen
Ahmet Cecen on 22 Aug 2014
Edited: Ahmet Cecen on 22 Aug 2014
Nope the above will give you the correct answer, without the need of additional weights. I am calculating the number of pixels at each image separately, so the inconsistency of dimensions between images are already accounted for.
Image Analyst
Image Analyst on 22 Aug 2014
Fabian: what Ahmet says is correct and in perfect agreement with what Michael said - the weighting is taken into account.
You should replace image(i) in his code with yourImage(:) or yourImage{i} (depending on how your image is stored) since you should not use image as the name of a variable.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!