developing clusters in a 3D image

17 vues (au cours des 30 derniers jours)
C.
C. le 9 Oct 2014
Commenté : Matt J le 13 Oct 2014
I am very new to MATLAB (and programming) and I'm probably out of my skill level in attempting this, but...
I need to write a script that can take a 3D image and given an x,y,z coordinate within that image test all adjacent coordinates to the given coordinate to see if any of them are greater than 0. If an adjacent coordinate is greater than zero I need to repeat the aforementioned process for this coordinate as well until all coordinates > 0 and branching from the original coordinate are exhausted. Could anyone perhaps give me any hints as to a basic method (not necessarily efficient) to accomplish this? I suspect this process has to be recursive?
Thanks
  1 commentaire
Image Analyst
Image Analyst le 9 Oct 2014
What do you want as an output after you're done doing the region growing (which is what it's called, not clustering). And it can be recursive but can be done in a single line of code by calling bwconncomp() or bwlabel().

Connectez-vous pour commenter.

Réponses (2)

Matt J
Matt J le 9 Oct 2014
Modifié(e) : Matt J le 9 Oct 2014
You could do this pretty easily with bwconncomp()
BW=Image>0;
BW(x,y,z)=true;
CC=bwconncomp(BW);
lidx=sub2ind(size(BW),x,y,z);
Now just loop through all CC(i).PixelIdxList and see which region contains lidx.
  2 commentaires
C.
C. le 13 Oct 2014
Modifié(e) : C. le 13 Oct 2014
Basically I am trying to find ROIs in an fMRI image using previous data about where these ROIs are (The coordinate is the max intensity voxel within an activation cluster). The script will start at this voxel and find all active neighbors until they are exhausted and produce a binary image with 1s in active voxels and 0s elsewhere. I'm a little confused by what the last line is doing, however.
lidx=sub2ind(size(BW),x,y,z);
Matt J
Matt J le 13 Oct 2014
It's converting the x,y,z coordinates to linear indeces, which is the format that the pixel coordinates are held in in CC(i).PixelIdxList.
See,

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 9 Oct 2014
Modifié(e) : Image Analyst le 9 Oct 2014
In addition to the way Matt said, you can use bwlabel and ismember
labeledImage = bwlabel(yourArray);
regionIWant = labeledImage(row, col, slice);
outputImage = ismember(labeledImage, regionIWant);
Or you could use imreconstruct to do a morphological reconstruction:
seedImage = false(size(yourArray));
seedImage(row, col, slice) = true;
outputImage = imreconstruct(seedImage, yourArray);

Community Treasure Hunt

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

Start Hunting!

Translated by