【问题标题】:Extracting Feature from an Image - suggestions for best approach?从图像中提取特征 - 最佳方法的建议?
【发布时间】:2016-07-22 16:41:53
【问题描述】:

我目前正在学习计算机视觉,我想从图像中提取洋葱。最好的方法是什么?

我尝试了一种阈值化方法,通过将图像分解为其 R、G、B 通道来检测白色,但它也可以检测图像其他部分的光反射。如何清理此图像以获得近似代表洋葱的蒙版?

onionRGB = imread('onion.png');
onionGRAY = rgb2gray(onionRGB);

figure, imshow(onionRGB);

% split channels
rOnion = onionRGB(:, :, 1);             % red channel
gOnion = onionRGB(:, :, 2);             % green channel
bOnion = onionRGB(:, :, 3);             % blue channel


whiteThresh = 160*3;
% detect white onion
onionDetection = double(rOnion) + double(gOnion) + double(bOnion);

% apply thresholding to segment the foreground
maskOnion = onionDetection > whiteThresh;
figure, imshow(maskOnion);

【问题讨论】:

    标签: matlab image-processing feature-detection feature-extraction


    【解决方案1】:

    下面的代码,在拆分成通道后放置,效果很好。

    onionHSV = rgb2hsv(onionRGB);
    saturationOnion = onionHSV(:,:,2);
    figure;
    imagesc(saturationOnion);
    title('Saturation');
    
    figure;
    imagesc(rOnion+bOnion); title('purple');
    
    %apply threshold to saturation and purple brightness levels
    maskOnion = and((saturationOnion < 0.645), (rOnion+bOnion >=155));
    %filter out all but the largest object
    maskOnion = bwareafilt(maskOnion,1);
    figure, imshow(maskOnion);
    

    第一个技巧是使用颜色的 HSV 表示中的饱和度进行过滤。 第二个技巧是在多个通道上设置阈值。 第三个技巧是过滤掉除最大对象之外的所有对象。

    【讨论】:

      猜你喜欢
      • 2020-04-25
      • 1970-01-01
      • 2015-06-20
      • 1970-01-01
      • 2018-07-08
      • 2012-08-15
      • 1970-01-01
      • 2012-06-20
      • 1970-01-01
      相关资源
      最近更新 更多