✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
????个人主页:Matlab科研工作室
????个人信条:格物致知。
更多Matlab仿真内容点击????
⛄ 内容介绍
医学图像分割在疾病诊断和治疗等领域中的作用日益重要.当前,主动轮廓模型已广泛地应用于医学图像分割领域.此模型对图像分割,可视化,配准和解剖组织跟踪等是很有效的.主动轮廓模型将复杂的分割转化为函数的极值问题,即曲线或曲面变形的依据是根据其定义的能量函数最小化原则.
⛄ 部分代码
function I=imgaussian(I,sigma,siz)
% IMGAUSSIAN filters an 1D, 2D color/greyscale or 3D image with an
% Gaussian filter. This function uses for filtering IMFILTER or if
% compiled the fast mex code imgaussian.c . Instead of using a
% multidimensional gaussian kernel, it uses the fact that a Gaussian
% filter can be separated in 1D gaussian kernels.
%
% J=IMGAUSSIAN(I,SIGMA,SIZE)
%
% inputs,
% I: The 1D, 2D greyscale/color, or 3D input image with
% data type Single or Double
% SIGMA: The sigma used for the Gaussian kernel
% SIZE: Kernel size (single value) (default: sigma*6)
%
% outputs,
% J: The gaussian filtered image
%
% note, compile the code with: mex imgaussian.c -v
%
% example,
% I = im2double(imread('peppers.png'));
% figure, imshow(imgaussian(I,10));
%
% Function is written by D.Kroon University of Twente (September 2009)
if(~exist('siz','var')), siz=sigma*6; end
if(sigma>0)
% Make 1D Gaussian kernel
x=-ceil(siz/2):ceil(siz/2);
H = exp(-(x.^2/(2*sigma^2)));
H = H/sum(H(:));
% Filter each dimension with the 1D Gaussian kernels\
if(ndims(I)==1)
I=imfilter(I,H, 'same' ,'replicate');
elseif(ndims(I)==2)
Hx=reshape(H,[length(H) 1]);
Hy=reshape(H,[1 length(H)]);
I=imfilter(imfilter(I,Hx, 'same' ,'replicate'),Hy, 'same' ,'replicate');
elseif(ndims(I)==3)
if(size(I,3)<4) % Detect if 3D or color image
Hx=reshape(H,[length(H) 1]);
Hy=reshape(H,[1 length(H)]);
for k=1:size(I,3)
I(:,:,k)=imfilter(imfilter(I(:,:,k),Hx, 'same' ,'replicate'),Hy, 'same' ,'replicate');
end
else
Hx=reshape(H,[length(H) 1 1]);
Hy=reshape(H,[1 length(H) 1]);
Hz=reshape(H,[1 1 length(H)]);
I=imfilter(imfilter(imfilter(I,Hx, 'same' ,'replicate'),Hy, 'same' ,'replicate'),Hz, 'same' ,'replicate');
end
else
error('imgaussian:input','unsupported input dimension');
end
end
⛄ 运行结果
⛄ 参考文献
[1]吴北海. 基于主动轮廓模型的医学图像分割[D]. 河北工业大学.