MATLAB Answers

Query in segmenting Nodules in LUNG CT

14 views (last 30 days)
Dear Friends, I am facing problem in segmenting a nodule from Lung CT scan. I segmented lung region from full CT slice using region growing method, but facing problem in segmenting a nodule from the lung region. I attached the full slice and segmented images. I need only the nodule part alone in my result image. I marked the nodule portion in the full slice image below. Please help me out friends :)

Accepted Answer

Sean de Wolski
Sean de Wolski on 17 Sep 2013
Edited: Sean de Wolski on 17 Sep 2013
Keep the biggest object that's not touching the border in your third image.
Inoborder = imclearborder(Your_Third_Image);
Imx = keepMaxObj(Inoborder);
keepMaxObj is this, though you could use regionprops and linear indexing explicitly.
function Imx = keepMaxObj(X)
%Function to keep only the maximum sized (biggest) object in an image
%SCd 11/30/2010
% -02/03/2011: Added ability to handle an image directly
% Imx = keepMaxObj(CC);
% Imx = keepMaxObj(V);
%Input Arguments:
% -CC: Connected components returned from bwconncomp
% -V: Logical image with parts you want true
%Output Arguments:
% -Imx: Logical volume with only the biggest object left true.
%See Also: bwconncomp
%Error checking:
assert(islogical(X)||isstruct(X),'The first input argument is expected to be a struct or a logical');
if isstruct(X)
CC = X;
parts = {'PixelIdxList','ImageSize'};
assert(all(ismember(parts,fieldnames(CC))),'CC is expected to be the output from bwconncomp');
CC = bwconncomp(X);
clear X;
%Preallocate and find number of voxels/object
Nvox = zeros(CC.NumObjects,1);
for ii = 1:CC.NumObjects
Nvox(ii) = numel(CC.PixelIdxList{ii});
%Find the biggest object's index, warn and save all if there are multiples
[mx,midx] = max(Nvox);
more_than1_max = sum(mx==Nvox);
if more_than1_max > 1
midx = find(mx == Nvox);
warning('Multiple:Maxima', 'There were %i objects with the maximum size.\n They are all left on!',more_than1_max);
%Create the final image
Imx = false(CC.ImageSize);
Imx([CC.PixelIdxList{midx}]) = true;

More Answers (1)

bimal khatiwada
bimal khatiwada on 9 Aug 2020
can any one help me with the matlab code to determine the spray length and spray cone angle please. for example: this fig:

Community Treasure Hunt

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

Start Hunting!