how to find maximum distance from centroid to border of binary image

조회 수: 7 (최근 30일)
sreerag kanhangad
sreerag kanhangad 2018년 6월 27일
답변: sreerag kanhangad 2018년 6월 27일
if true
% code
end
for ii=1:size(bord2,1)
for jj=1:size(bord2,2)
pixel(ii,jj)=bord2(ii,jj);
if(pixel(ii,jj)==1)
X = [xc yc;ii jj];
r1(c) = pdist(X,'euclidean');
c=c+1;
end
end
end

답변 (2개)

KSSV
KSSV 2018년 6월 27일
I = imread('peppers.png') ;
[nx,ny,d] = size(I) ;
C = round([ny nx]/2) ;
imshow(I)
hold on
plot(C(1),C(2),'*r')
R = [1 1 ; 1 nx ; ny nx ; ny 1] ; % four corners of the image
d = sqrt((C(1)-R(:,1)).^2+(C(2)-R(:,2)).^2) ;
  댓글 수: 6
sreerag kanhangad
sreerag kanhangad 2018년 6월 27일
if true
% code
end
%bord2 is bw image,[xc,yc]-centroid
[xd,yd]=find(bord2);
X = [xc yc;xd yd];
dnew=pdist(X,'euclidean');
dnew=max(dnew);
please check out this

댓글을 달려면 로그인하십시오.


sreerag kanhangad
sreerag kanhangad 2018년 6월 27일
yeah at last i got the output..misplaced jj and ii.. [y,x] = find(I) tysm for this idea

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by