Automatic segmentation of lungs from CT image
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 image0 commentaires
Réponses (1)
Image Analyst
le 1 Avr 2021
Modifié(e) : Image Analyst
le 1 Avr 2021
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 commentaires
Image Analyst
le 2 Avr 2021
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.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
