如何重新实现基于颜色的直方图,如何基于颜色和特征进行特征提取?在MATLAB中测量图像中的特征? [英] How do I re implement a color based histogram, do feature extraction based on color & measure features in an image in MATLAB?

查看:260
本文介绍了如何重新实现基于颜色的直方图,如何基于颜色和特征进行特征提取?在MATLAB中测量图像中的特征?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为此图片:

  1. 绘制颜色的R,G,B分量的直方图(不使用imhist)
  2. 将图片更改为二进制,使昆虫的棕色外骨骼为白色
  3. 测量昆虫的外骨骼的宽度和高度
  1. Draw histogram of R, G, B components of color (not using imhist)
  2. Change picture to binary so brown exoskeleton of insect is white
  3. Measure insect's exoskeleton's width and height

1: 我做到了:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆