Filter löschen
Filter löschen

Image not generated after separation..?

2 Ansichten (letzte 30 Tage)
Nimisha
Nimisha am 2 Jul. 2015
Kommentiert: Walter Roberson am 2 Jul. 2015
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 Kommentare
Nimisha
Nimisha am 2 Jul. 2015
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 am 2 Jul. 2015
What reason do you have to expect that there will definitely be 20 or more different labels?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by