How to segment lung from 2D images

3 visualizaciones (últimos 30 días)
AUWAL ABUBAKAR
AUWAL ABUBAKAR el 20 de Feb. de 2021
Respondida: Keerthana Chiruvolu el 23 de Feb. de 2021
Good day,
I have multiple 2D images from which I would like to segment the lung field from each. I successfully developed a code to do that, but it does not work for all the images as the contrast slightly vary from one image to the other (Image1 and 2 attached). I try using ‘imhistmatch’ to match the contrast between the images but without success. Please see my code below and the results obtained in fig.1. Could someone please help me modify the code to suit this purpose or suggest a better method to achieve this?
clear;clc;close all
% Ia=imread('image1.jpg');
load image1
II = adapthisteq(Ia,'clipLimit',0.02,'Distribution','rayleigh');
subplot(2,4,2);imshow(II);title('Adjusted contrast')
II(II>35000)=0;
II = bwareaopen(II,50); %remove connected components
mask = bwareafilt(II, 2); %There are small noise blobs. Extract the two largest objects.
z=ImageAnalyst(mask,-1); %Extract the 2nd largest objects.
subplot(2,4,1);imshow(Ia);title('Original image1')
subplot(2,4,3);imshow(z);title('segmented lung')
subplot(2,4,4);imshowpair(z,Ia);title('Image1/lung pair')
%%
% image2
% Ib=imread('image2.jpg');
load image2
I=imhistmatch(Ib, Ia);% adjust the histogram of 2D image to macth histogram of image1 image
I = adapthisteq(Ib,'clipLimit',0.02,'Distribution','rayleigh');
subplot(2,4,6);imshow(I);title('Adjusted contrast')
I(I>35000)=0;
I = bwareaopen(I,50); %remove connected components
mask = bwareafilt(I, 2); %There are small noise blobs. Extract the two largest objects.
z=ImageAnalyst(mask,-1); %Extract the 2nd largest objects ising ImageAnalyst funtion
subplot(2,4,5);imshow(Ib);title('Original image2')
subplot(2,4,7);imshow(z);title('segmented lung')
subplot(2,4,8);imshowpair(z,Ib);title('Image2/lung pair')
  3 comentarios
KALYAN ACHARJYA
KALYAN ACHARJYA el 20 de Feb. de 2021
More @AUWAL ABUBAKAR Are the images properly attached?
AUWAL ABUBAKAR
AUWAL ABUBAKAR el 20 de Feb. de 2021
Thanks for your response @KALYAN ACHARJYA and @darova. There was an error attaching the images. I have attached the variables now. Thanks

Iniciar sesión para comentar.

Respuestas (1)

Keerthana Chiruvolu
Keerthana Chiruvolu el 23 de Feb. de 2021
Hi,
Use the Image Segmenter App to segment the lungs from the images and generate binary mask easily. You can import the original image and export the mask directly to MATLAB Workspace.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by