2017-03-28 1 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