How to segment lung from 2D images

조회 수: 3 (최근 30일)
AUWAL ABUBAKAR
AUWAL ABUBAKAR 2021년 2월 20일
답변: Keerthana Chiruvolu 2021년 2월 23일
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
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 2월 20일
More @AUWAL ABUBAKAR Are the images properly attached?
AUWAL ABUBAKAR
AUWAL ABUBAKAR 2021년 2월 20일
Thanks for your response @KALYAN ACHARJYA and @darova. There was an error attaching the images. I have attached the variables now. Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

Keerthana Chiruvolu
Keerthana Chiruvolu 2021년 2월 23일
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.

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by