"imfilter"和"conv2"之间的区别[MATLAB] [英] Differences between 'imfilter' and 'conv2' [MATLAB]

查看:216
本文介绍了"imfilter"和"conv2"之间的区别[MATLAB]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这两个功能来查找刻度上的边.您有一个输入图像,您对输入图像应用了一个蒙版(例如,prewitt),并获得了最终的图片.

I use this both function to find edges on a scale. You have a input image, you apply a mask (for ex. prewitt) to the input image, and get the resultant pic.

mypic = imread('examplepic.jpg')
hy = fspecial('prewitt')
yimfilter = imfilter(mypic,hy) % Using imfilter
yconv2 = conv2(mypic,hy) % Using conv2

这两者之间的理论区别是什么?我知道我得到了不同的输出,但是有什么区别?

Which is the theorical difference between these two? I know I got different outputs, but which is the difference?

谢谢

推荐答案

conv2输出整个2D卷积,这意味着yconv2将比mypic大.另一方面,默认情况下,imfilter会修剪卷积的边缘,以便yimfilter的大小应与mypic相同.您可以像使conv2一样使imfilter离开整个卷积,但这不是它的默认行为.

conv2 outputs the entire 2-D convolution, which means that yconv2 will be bigger than mypic. imfilter, on the other hand, by default trims the edges of the convolution so that yimfilter should be the same size as mypic. You can make imfilter leave the entire convolution like conv2 does, but that is not its default behavior.

还有其他区别:imfilter的"replicate"选项,imfilter可以对任意数量的维度(不只是2个)进行卷积,依此类推,但是我不认为您是在问这个.

There are other differences: imfilter's "replicate" option, imfilter can do convolution on arbitrary numbers of dimensions (not just 2), and so on, but I don't think you were asking about that.

这篇关于"imfilter"和"conv2"之间的区别[MATLAB]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆