如何重新实现基于颜色的直方图,基于颜色和& ;;进行特征提取。在MATLAB中测量图像中的特征? [英] How do I re implement a color based histogram, do feature extraction based on color & measure features in an image in MATLAB?
本文介绍了如何重新实现基于颜色的直方图,基于颜色和& ;;进行特征提取。在MATLAB中测量图像中的特征?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于这个图片:
- 绘制颜色的R,G,B成分的直方图(不使用imhist)
- 将图片更改为二进制,使昆虫的棕色外骨骼为白色
- 测量昆虫外骨骼的宽度和高度
- Draw histogram of R, G, B components of color (not using imhist)
- Change picture to binary so brown exoskeleton of insect is white
- Measure insect's exoskeleton's width and height
编辑:
1:
我做到了:
1: I did that:
a = imread('C:\a.jpg');
r = a(:,:,1);
g = a(:,:,2);
b = a(:,:,3);
rhist = zeros(1,256);
[w h] = size(a(:,:,1));
for i=1:w
for j=1:h
rhist(r(i,j)+1) = rhist(r(i,j)+1)+1;
end
end
rhist(x)是红色强度的计数等于x-1
rhist(x) is count of red intensity that is equal to x-1
现在我只需要一点帮助如何将这些数据绘制成直方图
Now I just need a little help how to draw this data as a histogram
2:仍然,不知道:(。我正在使用im2bw与不同的第二个参数,但这没有帮助。
我猜一些模糊可能会有所帮助?
3 :也不知道。
2: Still, have no idea :(. I'm using im2bw with different second argument but that does not help.
I'm guessing that some blur might help?
3: No idea, too.
推荐答案
这是我的IMHIST版本:
Here is my version of IMHIST:
I = imread('pic.jpg');
II = double(I);
clr = 'rgb'; clrTxt = {'Red' 'Green' 'Blue'};
for i=1:3
h = subplot(3,1,i);
c = histc(reshape(II(:,:,i),[],1), 0:255);
bar(0:255, c./max(c), 'histc')
set(gca, 'XLim', [0 255], 'YLim',[0 1])
set(findobj(h,'Type','patch'), 'FaceColor',clr(i), 'EdgeColor','none')
ylabel(clrTxt{i})
end
xlabel('Intensity')
这篇关于如何重新实现基于颜色的直方图,基于颜色和& ;;进行特征提取。在MATLAB中测量图像中的特征?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文