医学影像分割

阅读: 评论:0

医学影像分割

医学影像分割

1.迭代阈值法

%迭代阈值法
clc;clear all;close all
I=imread('spine.tif');
% I=dicomread('CT-MONO2-16-ankle.dcm');
% I=rgb2gray(I);
subplot(1,2,1);imshow(I);title('(a) 原图');
I=double(I);T=(min(I(:))+max(I(:)))/2;
d=false;i=0;
while ~ du1=find(I<=T);u2=find(I>T);Tn=(mean(I(u1))+mean(I(u2)))/2;d=abs(Tn-T)<1;T=Tn;i=i+1;
end
I(u1)=0;I(u2)=1;
subplot(1,2,2);imshow(I);title('(b) 处理结果');

2.分水岭法

%分水岭法
clc;clear all;close all
I=imread('mri.tif');
%I=dicomread('C:MR-MONO2-12-angio-an1MR-MONO2-12-angio-an1');
%I=dicomread('C:MR-MONO2-16-kneeMR-MONO2-16-knee');
% I=rgb2gray(I);
subplot(2,2,1);imshow(I);title('(a) 原图');
I=double(I);hv=fspecial('prewitt');hh=hv.'
gv=abs(imfilter(I,hv,'replicate'));
gh=abs(imfilter(I,hh,'replicate'));
g=sqrt(gv.^2+gh.^2);
L=watershed(g);wr=L==0;
subplot(2,2,2);imshow(wr);title('(b) 分水岭');
I(wr)=255;
subplot(2,2,3);imshow(uint8(I));title('(c) 分割结果');
rm=imregionalmin(g);
subplot(2,2,4);imshow(rm);title('(d) 局部极小值');

3.边缘探测法

%边缘探测法
clc;clear all;close all
% I=imread('mri.tif');
I=dicomread('C:MR-MONO2-12-angio-an1MR-MONO2-12-angio-an1');
% I=dicomread('C:MR-MONO2-16-kneeMR-MONO2-16-knee');
% I=rgb2gray(I);
figure;subplot(2,3,1);imshow(I);title('(a) 原图');
I1=im2bw(I);
subplot(2,3,2);imshow(I1);title('(b) 二值图像');
I2=edge(I,'roberts');
subplot(2,3,3);imshow(I2);title('(c) roberts算子分割');
I3=edge(I,'sobel');
subplot(2,3,4);imshow(I3);title('(d) sobel算子分割');
I4=edge(I,'Prewitt');
subplot(2,3,5);imshow(I4);title('(e) Prewitt算子分割');
subplot(2,3,6);imhist(I);title('(f) 直方图');

4.区域生长法

%区域生长法
clc;clear all;close all
%I=imread('mri.tif');
I=dicomread('C:MR-MONO2-12-angio-an1MR-MONO2-12-angio-an1');
%I=dicomread('C:MR-MONO2-16-kneeMR-MONO2-16-knee');
% I=rgb2gray(I);
figure;
% seedx=[256, 128, 480];
% seedy=[128, 256, 384];
seedx=[128, 64, 255];
seedy=[64, 128, 192];
hold on
plot(seedx,seedy,'gs','linewidth',1);title('(a) 原图图像及种子质量');
figure;subplot(1,2,1);imshow(I);title('(a) 原图');
% seedx=[256, 128, 480];
% seedy=[128, 256, 384];
% hold on
% plot(seedx,seedy,'gs','linewidth',1);
% title('(a) 原图图像及种子质量');
I=double(I);
markerim=I==I(seedy(1),seedx(1));
for i=2:length(seedx)markerim=markerim | (I==I(seedy(i),seedx(i)));
end
thresh=[15, 10, 15];
maskim=zeros(size(I));
for i=1:length(seedx)g=abs(I-I(seedy(i), seedx(i)))<=thresh(i);maskim=maskim | g;
end
[g, nr]=bwlabel(imreconstruct(markerim, maskim),8);
g=mat2gray(g);
subplot(1,2,2);imshow(g)title('(b) 三个种子点区域生长结果');

5.直方图阈值分割法

% 直方图阈值分割法
clc;clear all;close all
I=imread('cell.tif');
% I=rgb2gray(I);
figure;subplot(1,3,1);imshow(I);title('(a) 原图');
subplot(1,3,2);imhist(I);title('(b) 直方图');
[m, n]=size(I);
for i=1:mfor j=1:nif I(i,j)>140    %阈值根据实际情况设置I(i,j)=255;endend
end
subplot(1,3,3);imshow(I);title('(c) 分割结果');

6.Otsu分割法

% Otsu分割法
clc;clear all;close all
I=imread('cell.tif');
% I=rgb2gray(I);
figure;subplot(1,2,1);imshow(I);title('(a) 原图');
count=imhist(I);
[r,t]=size(I);
N=r*t;
L=256;
count=count/N;
for i=2:Lif count(i)~=0st=i-1;breakend
end
for i=L:-1:1if count(i)~=0nd=i-1;breakend
end
f=count(st+1:nd+1);
p=st;
q=nd-st;
u=0;
for i=1:qu=u+f(i)*(p+i-1);ua(i)=u;
end
for i=1:qw(i)=sum(f(1:i));
end
d=(u*w-ua).^2/(w.*(1-w));
[y,tp]=max(d);
th=tp+p;
if th<=140th=tp+p;
elseth=140;
end
y1=zeros(r,t);
for i=1:rfor j=1:tx1(i,j)=double(I(i,j));end
end
for i=1:rfor j=1:tif x1(i,j)>=thy1(i,j)=x1(i,j);elsey1(i,j)=0;endend
end
subplot(1,2,2);imshow(y1);title('(b) 分割结果');

 

本文发布于:2024-02-04 19:44:53,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170715068158965.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:医学影像
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23