histogram values of an image

1 Ansicht (letzte 30 Tage)
kapil
kapil am 20 Feb. 2013
hey, i am doing a project on 'moment preserving thresholding' which essentially retrieves two threshold values from an input 'gray scale image'.
for getting the threshold values we perform certain operations and obtain p,p1,p2 values.
the value of threshold is then selected as follows, 'the thresholds t,t1, can be found from the histogram of image by choosing 't' as the p-tile and 't1' as (p+p1)-tile'
the values of p,p1,p2 are less than one(say p=0.361,pl=0.277,p2=0.362;).
my problem is how to obtain values from the histogram for such fraction values, since the values of p,p1,p2 are fractions less than 1.
this below is the test data set...
a=[10 8 10 9 20 21 32 30 40 41 41 40 12 10 11 10 19 20 30 28 38 40 40 39 10 9 10 8 20 21 30 29 42 40 40 39 11 10 9 11 19 21 31 30 40 42 38 40];
'a' is of size 4*12.
p=0.361; pl=0.277; p2=0.362;
selected thresholds are t=18,t1=30
can anyone help me to get over this problem.

Akzeptierte Antwort

Image Analyst
Image Analyst am 20 Feb. 2013
If (the badly named) a is a uint8 gray scale image (the most common type), then there should be 256 bins, and you can use this code:
[pixelCounts, grayLevels] = imhist(grayImage, 256);
Now you multiply your fraction t values by 255 to get its gray level equivalent. Then call int32(), round(), fix(), ceil(), or floor() and pay attention to the <, >, >= or <= for the comparison depending on which function you want to use.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by