how can imfill an image with a lot of edge?

7 visualizaciones (últimos 30 días)
sara
sara el 8 de Sept. de 2014
Comentada: Image Analyst el 20 de Mayo de 2017
hi
I want to imfill an image of lung to have an image that shows me just left and right lung.. I obtain boundary of lung wit this cod that I attach
if true
function [perimImage] = filling( I )
s = uint8(255 * mat2gray(I));
s = im2bw(s);
perimImage = xor(s,imerode(s, true(3)));
figure, imshow(perimImage)
end end
when I use this code my result is like the image that I put.
I think it is a good result but when I use imfill, the result is this:
do you have any suggestion for me to have an image like this after using imfill?
be black or white is not important for me I just want to segment lung to the result that I say.. thanks
  2 comentarios
Sean de Wolski
Sean de Wolski el 8 de Sept. de 2014
Editada: Sean de Wolski el 8 de Sept. de 2014
Show us the original image; it might be easier to start with that for the original segmentation.
sara
sara el 8 de Sept. de 2014
hi Sean
my original image is .tif so I attach this in a .zip
thanks

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 8 de Sept. de 2014
Draw lines around the border of your binary image:
binaryImage(:,1) = true;
binaryImage(:,end) = true;
binaryImage(1,:) = true;
binaryImage(end,:) = true;
Now do a fill to fill the region between the border and the body.
binaryImage = imfill(binaryImage, 'holes');
Now do an imclearborder to get rid of all that and leave just the lung edges
binaryImage = imclearborder(binaryImage);
Now do a fill again to get the lungs filled.
lungsMask = imfill(binaryImage, 'holes');
And you're basically done. If there is any small blobs remaining, use my ExtractNLargestBlobs function (attached) to extract just the 2 largest blobs, which will be the lungs.
  14 comentarios
sara
sara el 14 de Sept. de 2014
Editada: sara el 14 de Sept. de 2014
hi Image Analyst
I thouth our code is correct for every thing but when I tested it for this image that I attached I understood that the lung result should not have any holes but if you see this image and the result you can see in the bottom and left side of this lung we have a big hole...do you agree with me that if before using ExtractNLargestBlobs we use a circle mask the result can be better?
Image Analyst
Image Analyst el 14 de Sept. de 2014
It's not a "hole" but more of a "bay" because that region is actually a white region that is an incursion from the bright outer body into the lung. If you want to smooth the boundary you need to use active contours. This will "cut off" that bay. I'm attaching an example.

Iniciar sesión para comentar.


sara
sara el 11 de Sept. de 2014
hi Image Analyst I use otsu method instead of <45000 in this code and it gave me a good result I attach this.
  2 comentarios
Salma Hassan
Salma Hassan el 20 de Mayo de 2017
how did you get figure 4 (lungs only )
Image Analyst
Image Analyst el 20 de Mayo de 2017
Who are you asking? I gave my code above in this post: click here

Iniciar sesión para comentar.

Categorías

Más información sobre 3-D Volumetric Image Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by