Get coordinates from struct created with bwconncomp

Hello guys
I have a binary image as a prediction from a neural network. This image has several regions (vertebras of the spine). When i run bwconncomp(binary_image), i get as a result a struct with 17-19 Objects (vertebras). Now i need to find the coordinates of the regions. [y x] = find(binary_image) just gives me all coordinates, but i need this separated for each region, so 17-19 coordinate arrays. How do i get this?

 採用された回答

Matt J
Matt J 2021 年 4 月 28 日
編集済み: Matt J 2021 年 4 月 28 日

0 投票

Use regionprops instead,
stats=regionprops(BW,'PixelList')

6 件のコメント

Stefan Lang
Stefan Lang 2021 年 4 月 28 日
This gives me one array with all x and y coordinates. But i need to know, which of these coordinate pairs belongs to which of the 17-19 regions. Or i need 17-19 separate arrays.
Matt J
Matt J 2021 年 4 月 28 日
編集済み: Matt J 2021 年 4 月 28 日
This gives me one array with all x and y coordinates.
It shouldn't. I would attach your BW image in a .mat file so we can see what's happening.
Stefan Lang
Stefan Lang 2021 年 4 月 28 日
I only get one array with it.
Matt J
Matt J 2021 年 4 月 28 日
編集済み: Matt J 2021 年 4 月 28 日
I get 18 regions,
load('vertebras_lateral');
BW=logical(vertebras_lateral);
stats = regionprops(BW,'PixelList')
stats = 18×1 struct array with fields:
PixelList
Stefan Lang
Stefan Lang 2021 年 4 月 28 日
Ooh, i used the array and did not convert it into a logical. Now that worked. Thank you!
Matt J
Matt J 2021 年 4 月 28 日
You should have had the same problem with bwconncomp.

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

その他の回答 (0 件)

質問済み:

2021 年 4 月 28 日

コメント済み:

2021 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by