フィルターのクリア

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 Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by