【问题标题】:Counting the number of medium-sized buttons on the image using Matlab使用 Matlab 计算图像上中型按钮的数量
【发布时间】:2015-06-18 15:49:21
【问题描述】:

我尝试选择边框,然后计算面积。 Вut 我对此有一些困难。这是我的原图。

经过对原图的一些处理,我得到了这张图:

这是我的代码:

    clear;
    I=imread('C:\Users\Sashka\Desktop\calculator.jpg');
    i=rgb2gray(I);
    background = imopen(i,strel('disk',20));
    im=histeq(background, 64);
    uns=fspecial('unsharp') ;  
    uns1=imfilter(im, uns);
    bw = im2bw(uns1,0.3); 
    bw2=bwmorph(bw, 'close', Inf);
    bw3=bwmorph(bw2, 'majority', Inf);
    bw4=bwmorph(bw3, 'erode', 18);
    c=[30 30 440 440];
    r=[480 680 680 480];
    bw5=bwselect(bw4,c,r,4);
    I2=imcrop(bw5, [30 25 1300 1090]);

你能帮我数一下中号按钮的数量吗?

【问题讨论】:

  • 你要数所有的按钮吗?

标签: matlab image-processing object-recognition


【解决方案1】:

只需使用regionprops 并定义所需按钮的最大或最小区域的阈值,例如:

您的代码加上...

original = imcrop(i, [30 25 1300 1090]);

L_Measurements = regionprops(~I2, original, 'all');

threshold = 40000;
Areaofbuttons = cell2mat({L_Measurements.Area}');
numberOfButtons = sum( Areaofbuttons > threshold)

例如给出,

numberOfButtons =

     9

【讨论】:

  • 我的解决方案对您有帮助吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-03
  • 1970-01-01
  • 2013-08-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多