필터 지우기
필터 지우기

Image not generated after separation..?

조회 수: 2 (최근 30일)
Nimisha
Nimisha 2015년 7월 2일
댓글: Walter Roberson 2015년 7월 2일
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에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by