Can I get length in z dimension from bwlabeln?

I'm using bwlabeln to label objects in a binary 3D image stack. I need to know if each of these objects spans more than one section in the stack. Can anyone recommend a way to do this? Thanks

Respuestas (1)

Sean de Wolski
Sean de Wolski el 28 de Mayo de 2015
Editada: Sean de Wolski el 28 de Mayo de 2015
pixlist = regionprops(L,'PixelList')
Now look at pixlist's third column, i.e. z. If numel(unique(z))>1 there are multiple pages.
More - Example
%%Example data:
load mri
D = squeeze(D);
L = bwlabeln(D>50);
%%Engine
pixlist = regionprops(bwconncomp(L),'PixelList');
nobj = numel(pixlist);
for ii = nobj:-1:1
% multipage = 1, covers multiple pages, 0 does not.
multipage(ii,1) = numel(unique(pixlist(ii).PixelList(:,3)))>1;
end
% Find labels of multipage objects
multipageIdx = find(multipage);
% Keep only those in multipages
BW = ismember(L,multipageIdx);
% Relabel
Lmpage = bwlabeln(BW);
%%Check it
% How many multipage objects?
max(Lmpage(:))
% View as movie
implay(Lmpage);

2 comentarios

Tara
Tara el 28 de Mayo de 2015
brilliant thank you! Now just have to figure out how to exclude all objects that have that third column = 1. I'm a newbie to MATLAB so will no doubt take me days ;)
Sean de Wolski
Sean de Wolski el 28 de Mayo de 2015
See More for a full example.

Iniciar sesión para comentar.

Categorías

Más información sobre Biomedical Imaging en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Mayo de 2015

Comentada:

el 28 de Mayo de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by