Region Labelling

Asked by Adam on 8 May 2012
Latest activity Answered by Image Analyst on 8 May 2012

I would like to extract the lungs from an image, but as I'm new to matlab im unsure of how to go around this.

So far I have this:

    i=imread('Image1.png');
    t=graythresh(i);
    i2= im2bw(i,t);
     i3= edge(i2,'sobel');
    imshow(i3)
    bw2 = imfill(i4, 'holes');
    imshow(bw2)
    L = bwlabel(bw2);
    % colouredLabels = label2rgb(L, 'hsv','k','shuffle');
     Ex = regionprops(L, 'Centroid');
    hold on ;
    for k = 1:numel(L)
        c = Ex(k).Centroid;
        text(c(1),c(2),sprintf('%d',k),'HorizontalAlignment','center', 'VerticalAlignment','middle');
    end 

This so far, shows the thresholded image with each region labeled. What I'm trying to do is find and display the lungs, which would be over a certain area.

I've attempted to use something like his:

    allowableAreaIndexes = allBlobAreas > 100; 

combined with a couple other lines, but to no luck...

Would anyone be able to tell me how to go around this problem?

0 Comments

Adam

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst on 8 May 2012

You need to use ismember() as explained in my image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Here's the relevant snippet of code:

% Get a list of the blobs that meet our criteria and we need to keep. 
allowableIntensityIndexes = (allBlobIntensities > 150) & (allBlobIntensities < 220);
allowableAreaIndexes = allBlobAreas < 2000; % Take the small objects.
keeperIndexes = find(allowableIntensityIndexes & allowableAreaIndexes); 
% Extract only those blobs that meet our criteria, and 
% eliminate those blobs that don't meet our criteria. 
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes); 
% Re-label with only the keeper blobs kept.
labeledDimeImage = bwlabel(keeperBlobsImage, 8);     % Label each blob so we can make measurements of it
% Now we're done.  We have a labeled image of blobs that meet our specified criteria.
subplot(3, 3, 7); 
imshow(labeledDimeImage, []);
title('"Keeper" blobs (3 brightest dimes in a re-labeled image)');

Adapt it in the obvious ways (take out stuff about intensities, take out subplots, etc.).

0 Comments

Image Analyst

Contact us