Image not generated after separation..?

1 次查看(过去 30 天)
In this code finally image is not being generate. I have following code... I want to detect Lung cancer.
% This code reads image , extract the part of lung
% and then dispaly the result.
%%Read the image data
im=imread('LungSeg_01.png');
im=rgb2gray(im);
[row column]=size(im);
imshow(im)
title('the Original Image')
%%Get the threshold for segmentation using iteration process
%get the maximun and minimun value of the vector
Gmax=max(max(im));
Gmin=min(min(im));
%supposing T0 is the threshold
T0=(Gmax+Gmin)/2;
%mean of both parts,then get the new threshold T1
M0=mean(im(find(im<T0)));
M1=mean(im(find(im>=T0)));
T1=(M0+M1)/2;
%get the appropriate threshold
%by no more then 5000 loops
for i=1:5000 %here gives the maximun numbers of trying
if T1~=T0
T0=T1;
M0=mean(im(find(im<T0)));
M1=mean(im(find(im>=T0)));
T1=(M0+M1)/2;
else break
end
end
thresh=T0
%%Segmentation
for index=1:row*column
if im(index)>thresh
im(index)=0;
end
end
figure,imshow(im)
title('After Segmentation')
%make a copy,using to get the position
im0=im;
%%Extract
%divided the image into 2 parts
%foreground with 1,background with 0
for index=1:row*column
if im0(index)~=0
im0(index)=1;
end
end
%transform im0 into 'logical',then label
%the part of lung has been labelled with 20
im0=logical(im0);
im0=bwlabel(im0);
%display the relational pixel
for i=1:row*column
if im0(i)~=20
im(i)=0;
end
end
figure,imshow(im)
title('After Extract')
  3 个评论
Nimisha
Nimisha 2015-7-2
No, didnt getting any error. Just code is run without error. But final image is totally black.
I want to detect Lung cancer.
Walter Roberson
Walter Roberson 2015-7-2
What reason do you have to expect that there will definitely be 20 or more different labels?

请先登录,再进行评论。

回答(1 个)

drummer
drummer 2015-7-2
uHm... Did you try to set a displayrange in your imshow?
I don't know... it should work.
figure,imshow(im, 'DisplayRange', [])
  1 个评论
Walter Roberson
Walter Roberson 2015-7-2
[] is the default for imshow(). imagesc() uses the same as imshow(). It is image() that defaults to a different display range.

请先登录,再进行评论。

类别

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