2017-03-28 27 views
0

スケルトンの特定のポイントにのみ拡張を行うことが可能かどうかを知りたいと思います。例えば、以下のような画像を取得した場合、矩形の左上と左下の点に対応するスケルトンの点のみを拡大することは可能ですか? (各点の座標が知られているであろう) enter image description here特定のポイントの拡張

答えて

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'); 

、あなたは、この取得します: enter image description here

関連する問題