Get values inside connected components?

1 回表示 (過去 30 日間)
Mikhail  Kandel
Mikhail Kandel 2014 年 7 月 11 日
回答済み: Image Analyst 2014 年 7 月 12 日
me=zeros(5,5,5);
me(1:2,1:2,1:2)=rand(2,2,2);
me((end-1):end,(end-1):end,(end-1):end)=rand(2,2,2);
CC = bwconncomp(me);
STATS=regionprops(CC,me,'Image');
% Returns a binary mask,
% but I want the values inside `me`
% without needing to use the old bwlabeln interface
I want to eventually process each segment as a slice along the Z axis, and using a whole array for this is computationally expensive.
I have tried to use a bounding box but the box often has overlapping segments in 3d.

回答 (1 件)

Image Analyst
Image Analyst 2014 年 7 月 12 日
I'm not sure how to answer because I don't know what you want. Both bwconncomp() and regionprops() gives you the linear index of each labeled component - so just use it. If you want to get just one slice from the object, then use
cc = bwconncomp(binaryImage); % Do connected components analysis.
labeledImage = labelMatrix(cc); % Get the labeled image.
oneSlice = labeledImage(:,:,zValue); % Extract just one slice of it.
statsForOneSlice = regionprops(oneSlice, me, 'all'); % Measure the single slice.
Or something like that. Be more specific if you want better help.

Community Treasure Hunt

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

Start Hunting!

Translated by