Per = bwperim(img);

[r,c]=size(Per); p=1; z = nnz(Per); cord = zeros(z,2); for i=1:r for j=1:c if (Per(r,c)) == 1 cord(p,1)=i; cord(p,2)=j; p=p+1; p=p+1; end end end

42 views (last 30 days)

Show older comments

Hi

I have a binary image which I have extracted the perimeter with bwperim() function. Now that I have the perimeter image I am trying to extract the coordinates of pixels in this perimeter.Here are the images:

The white perimeter illustrated in the second image is where I want to find the coordinates. Any Suggestions is appreciated.

Thanks

Nitin
on 1 Apr 2014

Assuming your image is a binary one:

[a,b]= find(I==1); % get the coordinates

Dishant Arora
on 1 Apr 2014

If you have a single blob the above answer would suffice but in case you have multiple objects use bwboundaries. It gives you the coordinates of boundary pixels.

doc bwboundaries

Image Analyst
on 1 Apr 2014

Arriana Nwodu
on 13 Aug 2018

So which code is correct? I tried all the ways listed and it didn't work

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

Start Hunting!