how to find maximum distance from centroid to border of binary image
Show older comments
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
Answers (2)
KSSV
on 27 Jun 2018
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 Comments
sreerag kanhangad
on 27 Jun 2018
sreerag kanhangad
on 27 Jun 2018
KSSV
on 27 Jun 2018
That's more easy....get the locations of white pixels and use distance formula.
YOu need not to run a loop..get pixel values at once using:
[y,x] = find(I) ;
Now find the distance between (x,y) and your center C. Pick the maximum of it.
sreerag kanhangad
on 27 Jun 2018
KSSV
on 27 Jun 2018
You got your answer?
sreerag kanhangad
on 27 Jun 2018
0 votes
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
