Automatic segmentation of lungs from CT image

23 ビュー (過去 30 日間)
SILPA C S
SILPA C S 2021 年 4 月 1 日
コメント済み: Image Analyst 2021 年 4 月 2 日
I am trying to segment lungs from CT image, but while using Otsu method, some other regions (aroung lungs) also coming. Can some one help me to clear this problem? I can't use any manual technique. Need automatic lungs segmentation.
I=imread('NCP_39_1211_0023.png');
grayImage=I;
subplot(2, 3, 1);
imshow(grayImage, []);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
axis on;
title('Original Grayscale Image');
[pixelCount, grayLevels] = imhist(grayImage);
pixelCount(1) = 0;
pixelCount(end) = 0;
subplot(2, 3, 2);
bar(grayLevels, pixelCount, 'BarWidth', 1, 'FaceColor', 'b');
grid on;
title('Histogram of Original Image');
%thresholdValue = 250;
%binaryImage = grayImage < thresholdValue;
level = graythresh(grayImage)
BW = imbinarize(I,level);
binaryImage = BW;
subplot(2, 3, 3);
imshow(binaryImage, []);
axis on;
title('Binary Image');
% Get rid of stuff touching the border
%binaryImage = imclearborder(binaryImage);
% Extract only the two largest blobs.
binaryImage = bwareafilt(binaryImage, 1);
% Fill holes in the blobs to make them solid.
binaryImage = imfill(binaryImage, 'holes');
% Display the binary image.
subplot(2, 3, 4);
imshow(binaryImage, []);
axis on;
title('Lungs-Only Binary Image');
drawnow;
% Mask image with lungs-only mask.
% This will produce a gray scale image in the lungs and black everywhere else.
maskedImage = grayImage; % Initialize
maskedImage(~binaryImage) = 0;
% Display the masked gray scale image of only the lungs.
subplot(2, 3, 5);
imshow(maskedImage, []);
axis on;
title('Masked Lungs-Only Image');
Input image
Result image

回答 (1 件)

Image Analyst
Image Analyst 2021 年 4 月 1 日
編集済み: Image Analyst 2021 年 4 月 1 日
Looks like your automatic threshold was no good. And that's not the only thing. The image is total garbage. Way oversaturated. Try a different threshold, like around 150 or so.
thresholdValue = 150; % Automatic lungs segmentation at fixed threshold of 150
binaryImage = grayImage < thresholdValue;
% level = graythresh(grayImage)
% BW = imbinarize(I,level);
% binaryImage = BW;
  7 件のコメント
SILPA C S
SILPA C S 2021 年 4 月 2 日
編集済み: SILPA C S 2021 年 4 月 2 日
Sir @Image Analyst, in my program I'm accessing large number of CT images from a folder. For certain images 150 gives good segmentation. For some other 200, 250 like that. So each time I have to change values by seeing histogram. That's what I meant by manual. I would like to find a way where no such adjustment required each time. Sir, Is there any way to do this using histogram or any other way
Image Analyst
Image Analyst 2021 年 4 月 2 日
There are lots of ways. One way is to use a triangle threshold. Code is attached.
Another way might be to find the peak and just fall down the peak to a certain percentage of the peak. There are other possible ways one might think up.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by