【问题标题】:Get region points from MSER detection in MATLAB?从 MATLAB 中的 MSER 检测中获取区域点?
【发布时间】:2012-12-28 04:44:44
【问题描述】:

MSER detection in Matlab 之后,返回的 MSER 区域是椭圆。我们如何获得构成每个区域的确切点?

简单代码:

REGIONS = detectMSERFeatures(I)

在 OpenCV 中,我们得到拟合的椭圆以及区域的点(作为轮廓)。我找不到任何从 Matlab MSER 参数到 OpenCV 参数的直接映射。所以坚持使用 Matlab 检测 MSER。

但是,除了拟合椭圆之外,还有什么方法可以获取构成区域的实际点

【问题讨论】:

    标签: matlab opencv image-processing computer-vision matlab-cvst


    【解决方案1】:

    编辑: 您可以使用 Plot MSER regions property 获得您想要的分数,例如(来自 matlab 文档):

    regions = detectMSERFeatures(I);
    imshow(I);hold on;
    plot(regions);
    

    绘制 MSER 区域

    figure; imshow(I);hold on;
    plot(regions,'showPixelList',true, 'showEllipses',false);
    hold off;
    

    原答案:

    REGIONS 将为您提供信息regarding the Centroid (X0,Y0) the orientation angle (phi) and the minor and major axes(或它们的一半:椭圆的 a、b 参数)。

    质心:具有与 MSER 区域相同的二阶矩的椭圆的 [x y] 质心坐标的 M×2 数组。 :一个二元素向量,[majorAxis minorAxis]。该向量指定具有与 MSER 区域相同的第二矩的椭圆的长轴和短轴。 方向:范围从 -pi/2 到 +pi/2 弧度的值。该值表示从 X 轴到椭圆长轴测量的椭圆方向。

    您可以在每个存储区域(或 COUNT 属性)上使用以下代码进行循环。

    要绘制椭圆的轮廓,您可以使用以下代码:

    % These are just values to play with
    a=10;
    b=20;
    phi=0.5236;
    X0=40;
    Y0=50;
    
     R  = [ cos(phi) sin(phi); -sin(phi) cos(phi) ];
     theta_r         = linspace(0,2*pi);
     ellipse_x_r     = X0 + a*cos( theta_r );
     ellipse_y_r     = Y0 + b*sin( theta_r );
     rotated_ellipse = R * [ellipse_x_r;ellipse_y_r];
    
     plot( rotated_ellipse(1,:),rotated_ellipse(2,:),'b' );
    

    【讨论】:

    • 如果我的问题不清楚,我很抱歉。我不是要画椭圆的轮廓,而是 MSER 本身的轮廓。这个 MSER 本身就是一个区域,由点组成。这就是我想要得到的。
    • plot(regions,'showPixelList',true, 'showEllipses',false); 还没有回答您的问题吗?
    【解决方案2】:

    您可以使用以下方法获取每个区域的所有坐标:

    for i=1:length(regions) 
        coordinates=getfield(regions(i),'PixelList');
    end
    

    【讨论】:

      猜你喜欢
      • 2018-05-15
      • 2018-06-17
      • 2017-02-25
      • 2011-10-19
      • 2011-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-11
      相关资源
      最近更新 更多