MATLAB Answers

Segmentation of Lungs from Chest X-Ray Images

조회 수: 37(최근 30일)
Rida Memon
Rida Memon 22 Jan 2020
댓글: Rida Memon 24 Jan 2020
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.

  댓글 수: 0

로그인 to comment.

답변(2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 22 Jan 2020
편집: KALYAN ACHARJYA 22 Jan 2020
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 22 Jan 2020
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?

로그인 to comment.


Image Analyst
Image Analyst 22 Jan 2020

  댓글 수: 1

Rida Memon
Rida Memon 24 Jan 2020
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);

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by