How can I find pixel coordinates of a perimeter in a binary image?

12 ビュー (過去 30 日間)
Milad
Milad 2014 年 4 月 1 日
コメント済み: Cam S 2019 年 7 月 18 日
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
  3 件のコメント
Image Analyst
Image Analyst 2017 年 3 月 3 日
編集済み: Image Analyst 2017 年 3 月 3 日
mahesh, put this as an "Answer" below, not a comment up here. Also your entire code could be done in the single line
[rows, columns] = find(bwperim(img));
which is about the same at Nitin's accepted answer. However, neither that, nor your code will give the perimeter in a contiguous, connected way, like going clockwise around the region. It will give them on a column by column disconnected basis.
Cam S
Cam S 2019 年 7 月 18 日
yes exactly! how do you do that image analyst

サインインしてコメントする。

採用された回答

Nitin
Nitin 2014 年 4 月 1 日
Assuming your image is a binary one:
[a,b]= find(I==1); % get the coordinates
  2 件のコメント
Milad
Milad 2014 年 4 月 1 日
Thanks Nitin for the answer. It worked.
Dishant Arora
Dishant Arora 2014 年 4 月 1 日
If it works accept the answer.

サインインしてコメントする。

その他の回答 (2 件)

Dishant Arora
Dishant Arora 2014 年 4 月 1 日
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
  3 件のコメント
Dishant Arora
Dishant Arora 2014 年 4 月 1 日
First one is the co-ordinates of boundary pixels and second is a labelled image. What output do you get from find()?? Post your code.
Image Analyst
Image Analyst 2014 年 4 月 1 日
I agree with Dishant that bwboundaries is what you want , not bwperim followed by find. The difference in sizes between find and bwperim is probably due to bwboundaries "cutting corners" as it makes a 45 degree path while perim will give you all the rows and columns of the "L". Also find probably does not "follow the boundary" like bwboundaries does. With find you are not gauranteed that the pixel at the kth index is next to the pixel at the (k+1)st index since find probably goes in column major order like most things in MATLAB.

サインインしてコメントする。


Arriana Nwodu
Arriana Nwodu 2018 年 8 月 13 日
So which code is correct? I tried all the ways listed and it didn't work

Community Treasure Hunt

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

Start Hunting!

Translated by