How to find clusters in binary 3D image?

1 回表示 (過去 30 日間)
Sepp
Sepp 2015 年 7 月 10 日
コメント済み: Image Analyst 2015 年 7 月 16 日
Hello
I have a binary 3D image, i.e. it contains only 0 and 1. Now I want to find all clusters of 1s (i.e. clusters of voxels containing only value 1). Finally for each cluster I should know the coordinates of the voxels belonging to that cluster.
How can this be done? Of course I can iterate over all voxels but the difficulty is to detect the clusters and extract all voxels inside the cluster.

採用された回答

Image Analyst
Image Analyst 2015 年 7 月 10 日
Use bwlabeln() or bwconncomp(). If you really need the (x,y,z) coordinates of each voxel in a labeled blob, then you can call regionprops() and ask for PixelIdxList.
  2 件のコメント
Sepp
Sepp 2015 年 7 月 16 日
編集済み: Sepp 2015 年 7 月 16 日
Thank you very much for your answer.
The binary 3D image is of size 60 x 90 x 10. With the following Matlab code I'm searching for connected voxels of 1s in the image:
conn = 26;
CC = bwconncomp(img, conn);
stats = regionprops(CC,'pixellist');
The really weird thing is that stats returns coordinates which are outside of the 3D image.
For example for
voxels = stats(6).PixelList;
voxels(23,:)
I'm getting a 3D coordinate of (61,15,4).
What is wrong here? Regarding this issue I'm also concerned that the calculation of the connected components is wrong.
Here is the 3D image (as .mat file): https://www.dropbox.com/s/pw3yzbcx4uyhh9s/img.mat?dl=0
Image Analyst
Image Analyst 2015 年 7 月 16 日
You've made probably the most common mistake novice users make : confusing x and y with row and column. Remember, all matrices in MATLAB are indexed by row and column, NOT by x and y. So it's M(row, column) = M(y,x), and NOT M(x,y) because x is not the row - it's the column.
PixelList returns a x,y,z vector. You have a matrix that you say is 60x90x10 which I assume is rows by columns by slices. So the max of x is 90, the max of y is 60, and the max of Z is 10. So a coordinate of (x,y,z) = (61,15,4) is well within the range of your matrix bounds of (90,60,10).

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by