Categorise pixel gray values?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I need to be able to categorise pixel grayscale values for an ROI. The image is a 8-bit image (so 0-255). I want to categorise pixel according to their intensity, eg 0-50, 51-100, 101-150 etc... Then to be able to calculate the percentage in each category and then map the pixels to the categories into a colour and create a new image. Any help would be great! Thanks
Richard
댓글 수: 0
답변 (2개)
Jan
2011년 7월 4일
What did you try and where exactly is the problem?
What about a simple devision?
Im_uint8 = uint8(rand(100, 100) * 256);
Im_categ = fix(double(Im_uint8 - 1) / 50) + 1;
% 0-255 -> 1:6
% Be aware that the the 6th bin contains 251:255 only
Now create a map with 6 colors and create an RGB image:
map = [0,0,0; 0.5,0,0; 1,0,0; ...
1,0.5,0; 1.0,1,0; 1,1,0.5];
RGB = ind2rgb(Im_categ, map);
image(RGB);
댓글 수: 1
Andrei Bobrov
2011년 7월 4일
+1
Andrei Bobrov
2011년 7월 4일
my variant ( EDIT )
A = randi(255,10);
x = 0:51:255;
x(end) = x(end)+100*eps;
[n nb] = histc(A(:),);
B=A;
B(:)=nb;
댓글 수: 2
Jan
2011년 7월 4일
0:51:255 sets one limit to 102, but the OP wanted "0-50, 51-100, 101-150". But your 51 elements per bin seems to be more logical. I'd set the last limit to 256, otherwise the 255 get's it own bin.
Andrei Bobrov
2011년 7월 5일
@Jan, agree with you
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!