0
我想知道是否可以僅在骨架的某些點上進行擴張。例如,如果我們在下面的圖像中拍攝圖像,只能擴大與矩形的左上角和左下角對應的骨架點? (每個點的座標將被稱爲) 特定點的擴張
我想知道是否可以僅在骨架的某些點上進行擴張。例如,如果我們在下面的圖像中拍攝圖像,只能擴大與矩形的左上角和左下角對應的骨架點? (每個點的座標將被稱爲) 特定點的擴張
只是用另一個陣列上應用擴張:
% 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');