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!