histogram values of an image
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Image Analyst
2013년 2월 20일
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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!