开发者

How to convolve 2d signal with a 1D kernel without using loops in matlab?

开发者 https://www.devze.com 2023-02-22 04:02 出处:网络
I have an image.I want to convolve it.I have different type of kernels for both x and y directions. In the function con(u, v) we can only specify one vector and we have to use loops. For conv2(A, B) w

I have an image. I want to convolve it. I have different type of kernels for both x and y directions. In the function con(u, v) we can only specify one vector and we have to use loops. For conv2(A, B) we have to specify a composite kernel. I want to approximate 2d convolution with a开发者_如何学C series of 1D convolutions.


You can use CONV2 without problems.

For example, with one 1D filter being firstFilter = [1 1 1]/3, and the other 1D filter being secondFilter = [1 0 1]'/2, you can write the following:

out = conv2( conv2( yourImage, firstFilter, 'same'), secondFilter, 'same');
0

精彩评论

暂无评论...
验证码 换一张
取 消