http://mathforum.org/kb/message.jspa?messageID=6998158

 

graycomatrix가 [0,255] 사이의 이미지 입력 시 [0,8]으로 변환되는 이유

 

the Numlevels parameter is used to scale the image into (even?) bins.
So when you would calculate the graycomatrix of a vector goint from 0 to 255 and you set Numlevels to 8. You should get 32 , 1's,2's,...,8's.

B(1,:) = 0:31;
B(2,:) = 32:63;
B(3,:) = 64:95;
B(4,:) = 96:127;
B(5,:) = 128:159;
B(6,:) = 160:191;
B(7,:) = 192:223 ;
B(8,:) = 224:255;
[m,SI] = graycomatrix(B,'NumLevels',8,'GrayLimits',[0 255]);
for i = 1 : 8
numel(find(SI==i))
end

INSTEAD : matlab returns following bins (as can be seen in SI)
Graylevel values
Bin1 = 0-18;
Bin2 = 19-45;
...
While they should all be 32 in size.

WHY ARE THEY NOT EVENLY SCALED ???

Sincerely

------------------------------

 

 

 

It's because of rounding - look at the SI matrix. Anything between 0
and 18 is less than 0.5 and so gets set to 1, anything from 19 to 45
gets scaled to between 0.5 and 1.5 which gets set to 2, and so on up
to 236 - 255 which gets scaled to 7.5 to 8 which gets set to 8.
You're assuming that the gray levels less than 32 when divided by 32
and multiplied by 8 all go to 1 and that is not true for the reasons
given above - only half of them do.

You will have only half as many numbers at the low end and the high
end because there are only half as many numbers that go into the
ranges 0-.5 and 7.5-8 as there are that go into [n-.5 to n+.5].

'Matlab ' 카테고리의 다른 글

Map grayscale to color using colormap  (0) 2017.02.06
GraycoProps의 Contrast가 계산되는 방법  (0) 2017.02.03
Running MATLAB function from Java  (0) 2017.02.01
dist function substitution code  (0) 2017.01.13
윈도우 octave 옥타브 설치  (0) 2017.01.03
Posted by uniqueone
,