Segmentation of Lungs from Chest X-Ray Images

13 次查看(过去 30 天)
I need to segment the lungs from some Chest X-Ray images. I need the best code for this purpose if someone can provide that. Threshold or region based segmentation is much preferable.

回答(2 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020-1-22
编辑:KALYAN ACHARJYA 2020-1-22
There is no best code for Segmentation of Lungs from Chest X-Ray Images. The code depends on datasets or simmilar data types. The objectice of the code have to write the code, which may sutable for universal all images having simmilar types, though quite challenging, hence write the code which is best suitable for some wll verified public images multiple databases.
The segmentation approach is depends on test images, it would be better to comment more, if you can share a sample image. If the the ROI is distinctly differ from the rest part of the image, do threshold (recommended too, if it helps), otherwise with go with region growing or other segmentation methods and see theresults, you will be know which methods works for those images. There are so many approaches, request to follow the Gonzalez image processing using MATLAB book (Image Segmentation) for basic foundation.
Good Wishes!
  1 个评论
Rida Memon
Rida Memon 2020-1-22
I've used the chest xray images from the JSRT dataset. I am unable to attach the image of that type over here. Could you provide me any universally accepted code for lung segmentation?

请先登录,再进行评论。


Image Analyst
Image Analyst 2020-1-22
  2 个评论
Rida Memon
Rida Memon 2020-1-24
Kindly help me remove this error from my code. Where do i need to set the dimensions? Kindly explain
CODE:
fid = fopen('JPCLN001.img','r','b'); %image from JSRT dataset
oneSlice = fread(fid, [2048 2048], '*uint16','b');
img = mat2gray(oneSlice, [0,4096]);
img1 = imrotate(img,-90);
figure(101);
imshow(img1);
fclose(fid);
colormap(gray);
title('Grayscale X-Ray');
I=wiener2(img1, [5 5]);
figure(102);
subplot(2,1,1);
imshow(I);
subplot(2,1,2);
imhist(I, 256);
a_thresh = I >= 172; % set this threshold
[labelImage, numberOfBlobs] = bwlabel(a_thresh);
props = regionprops(a_thresh,'all');
sortedSolidity = sort([props.Solidity], 'descend');
SB = sortedSolidity(1);
if SB == 1 % SB only accept solidity == 1 filter out bones
binaryImage = imbinarize(I); figure(103);
imshow(binaryImage); colormap(gray);
SE = strel('square',3);
morphologicalGradient = imsubtract(imdilate(binaryImage, SE),imerode(binaryImage, SE));
mask = imbinarize(morphologicalGradient,0.03);
SE = strel('square',2);
mask = imclose(mask, SE);
mask = imfill(mask,'holes');
mask = bwareafilt(mask,2); % control number of area show
notMask = ~mask;
mask = mask | bwpropfilt(notMask,'Area',[-Inf, 5000 - eps(5000)]);
showMaskAsOverlay(0.5,mask,'r'); % you have to download app/function showMaskAsOverlay
BW2 = imfill(binaryImage,'holes');
new_image = BW2 ;
new_image(~mask) = 0; % invert background and holes
B=bwboundaries(new_image); % can only accept 2 dimensions
figure(104);
imshow(new_image);
hold on
visboundaries(B);
end
ERROR:
Warning: Image is too big to fit on screen; displaying at 33%
> In images.internal.initSize (line 71)
In imshow (line 309)
In a (line 6)
Index exceeds matrix dimensions.
Error in a (line 21)
SB = sortedSolidity(1);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Biomedical Imaging 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by