Find clusters with specific value in 3D matrix
10 views (last 30 days)
Show older comments
Hello,
I have an image of the size (91*109*91). The image contains voxels with values from 0 to 1. Now I would like to discard all voxels instead of those meeting the following conditions:
- They have a value smaller than .05
- they are part of cluster (connected voxels) of minimum 30 voxels with value < .05
At the end, I would like to have a 91*109*91 matrix/image containing only clusters of voxels with a value < 0.05.
I can figure out the first condition, what’s tricky for me is the second condition.
1 Comment
Accepted Answer
Matt J
on 20 Feb 2019
Edited: Matt J
on 21 Feb 2019
S=regionprops(yourImage<0.05,'Area','PixelIdxList');
S=S([S.Area]>=30); %edited
result=zeros(size(yourImage));
for i=1:numel(S)
idx=S(i).PixelIdxList;
result(idx)=yourImage(idx);
end
3 Comments
Matt J
on 20 Feb 2019
Never mind regionprops3.Here's a version with regionprops
S=regionprops(yourImage<0.05,'Area','PixelIdxList');
S=S([S.Volume]>=30);
result=zeros(size(yourImage));
for i=1:numel(S)
idx=S(i).PixelIdxList;
result(idx)=yourImage(idx);
end
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!