4
我有一個分段肝臟。我需要在其中分割腫瘤。我使用FCM方法。這是一個3級FCM閾值。當我將它應用於圖像時,我需要將腫瘤區域(比其餘部分更暗的區域)單獨分割。但是我們正好相反。腫瘤周圍的所有區域都被分割。請幫助我。該方案有兩個文件,testfcmthresh.m
和功能fcmthresh.m
使用Matlab進行腫瘤分割的模糊C手段
輸入「分割的肝臟(使用區域生長)」和FCM輸出圖像:
我試圖補充圖像通過使用imcomplement()
獲得但我得到的整個背景也是白色的,因爲背景本來是黑暗的。請幫助我。
function [bw,level]=fcmthresh(IM,sw)
%FCMTHRESH Thresholding by 3-class fuzzy c-means clustering
% [bw,level]=fcmthresh(IM,sw) outputs the binary image bw and threshold level of
% image IM using a 3-class fuzzy c-means clustering. It often works better
% than Otsu's methold which outputs larger or smaller threshold on
% fluorescence images.
% sw is 0 or 1, a switch of cut-off position.
% sw=0, cut between the small and middle class
% sw=1, cut between the middle and large class
%
% Contributed by Guanglei Xiong ([email protected])
% at Tsinghua University, Beijing, China.
% check the parameters
if (nargin<1)
error('You must provide an image.');
elseif (nargin==1)
sw=0;
elseif (sw~=0 && sw~=1)
error('sw must be 0 or 1.');
end
data=reshape(IM,[],1);
[center,member]=fcm(data,3);
[center,cidx]=sort(center);
member=member';
member=member(:,cidx);
[maxmember,label]=max(member,[],2);
if sw==0
level=(max(data(label==1))+min(data(label==2)))/2;
else
level=(max(data(label==2))+min(data(label==3)))/2;
end
bw=im2bw(IM,level);
%testfcmthresh.m
clear;clc;
im=imread('mliver3.jpg');
fim=mat2gray(im);
level=graythresh(fim);
bwfim=im2bw(fim,0.1);
[bwfim0,level0]=fcmthresh(fim,0);
[bwfim1,level1]=fcmthresh(fim,1);
subplot(2,2,1);
imshow(fim);title('Original');
subplot(2,2,2);
imshow(bwfim);title(sprintf('Otsu,level=%f',level));
subplot(2,2,3);
imshow(bwfim0);title(sprintf('FCM0,level=%f',level0));
subplot(2,2,4);
imshow(bwfim1);title(sprintf('FCM1,level=%f',level1));
% imwrite(bwfim1,'fliver6.jpg');
我們可以有腫瘤和肝臟的照片嗎? – Blender 2012-03-01 06:53:00
我是新用戶。所以我不能在這裏發佈圖片。如果你給我你的ID,我會把它發送給那個。提前致謝。附:我的項目正在使用Matlab – Gomathi 2012-03-01 08:00:05
將它們上傳到某個地方並將鏈接放在問題中。我將編輯圖像。 – Blender 2012-03-01 08:18:11