博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
让你弄明白高斯核是怎样进行滤波工作的
阅读量:6934 次
发布时间:2019-06-27

本文共 2078 字,大约阅读时间需要 6 分钟。

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) % 默认的高斯核大小是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

先是对行进行卷积,再是对列进行卷积。

转载地址:http://zrgjl.baihongyu.com/

你可能感兴趣的文章
C#正则表达式的完全匹配、部分匹配及忽略大小写的问题
查看>>
【游戏开发】基于VS2017的OpenGL开发环境搭建
查看>>
洛谷P3960 列队(动态开节点线段树)
查看>>
RESTful到底是什么玩意??
查看>>
PHP的词法解析器:re2c
查看>>
Html5版本的全套股票行情图开源了,附带实现技术简介
查看>>
Our Proof : Page Scraping : Website Data Extraction : Data Mining Analytics : Connotate.com
查看>>
linux 时间戳及时间差计算
查看>>
[Dynamic Language] Python 静态方法、类方法、属性
查看>>
在 Delphi 下使用 DirectSound (5): 获取或设置缓冲区的格式:
查看>>
select 语句的执行顺序
查看>>
wayos利用easyradius实现WEB认证页面的记住密码及到期提醒功能
查看>>
软件工程 软件的估计为什么这么难
查看>>
struts2标签
查看>>
[Cocoa]深入浅出Cocoa之多线程NSThread
查看>>
Silverlight运行原理经典问答。
查看>>
服务器
查看>>
15+ 提升技能的 jQuery 教程
查看>>
.NET的3C:CTS、CLS和CLR 以及 IL
查看>>
VS2010 ASP.NET MVC4 安装失败问题
查看>>