【问题标题】:Dilation of specific points [closed]特定点的膨胀[关闭]
【发布时间】:2017-03-28 08:07:28
【问题描述】:

我想知道是否可以只在骨架的某些点上进行扩张。例如,如果我们在下面拍摄图像,是否可以只扩大与矩形左上角和左下角对应的骨架点? (每个点的坐标都是已知的)

【问题讨论】:

    标签: matlab mathematical-morphology


    【解决方案1】:

    只需使用另一个数组来应用膨胀:

    % create example matrix
    A = false(100);
    A([2 end-1],[2:end-1]) = 1;
    A([2:end-1],[2 end-1]) = 1;
    A(sub2ind(size(A),2:99,2:99)) = 1;
    A(sub2ind(size(A),99:-1:2,2:99)) = 1;
    subplot(121);
    imshow(A);
    title('original');
    % decide points for dilation
    pointsForDilation = [2,2;9,9,;99,99];
    hold on;
    plot(pointsForDilation(:,1),pointsForDilation(:,2),'xr','MarkerSize',10,'LineWidth',2);
    % create a matrix for dilation
    B = false(size(A));
    B(sub2ind(size(B),pointsForDilation(:,2),pointsForDilation(:,1))) = 1;
    % dilate matrix B
    C = imdilate(B,ones(5));
    % add dilated matrix to original
    res = A | C;
    subplot(122);
    imshow(res);
    title('desired points dilated');
    

    你会得到这个:

    【讨论】:

      猜你喜欢
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多