Centroid calculation for connected component in 3D volume
Show older comments
I am trying to implement brain tumor segmentation on 3D brain MRI(.mha data type). After preliminary segmentation, I am applying 26-neighbor connected component algorithm(using bwconncomp) to obtain the largest connected component with maximum volume, following which I need to calculate the centroid of this connected component.
I am not sure if my method of calculating the largest connected component and the centroid is correct, because the centroid value obtained and its nearby voxels all have value 0. Also I dont know how 3D index is represented. For eg. if centroid=(x,y,z), does it correspond to x=row,y=column and z=2D slice?
Any help would be appreciated. Below is my code with the relevant part.
CC=bwconncomp(Ibin,26); %Input Black & White 3D data of size 240x240x155
Pixelid=regionprops(CC,'PixelIdxList');
[prow pcol]=size(Pixelid);
maxval=Pixelid(1).PixelIdxList;
index=1;
for i=1:prow
number=numel([Pixelid(i).PixelIdxList]); %calculating the component with max number of voxels
if(number>maxval)
maxval=number;
index=i;
end
end
for i=1:prow
if i~=index
Ibin(Pixelid(i).PixelIdxList)=0;
end
end
CC1=bwconncomp(Ibin,26);
Cent=regionprops(CC1,'Centroid');
Accepted Answer
More Answers (0)
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!