Create a 7x7 convolution kernel which has an equivalent effect to three passes with a 3x3 mean filter.
4 次查看(过去 30 天)
显示 更早的评论
How do I create a 7x7 convolution kernel that would have the have the same effect as 3 passes of a 3x3 mean filter. Assume I have a picture thats 7x7, just trying to quicken up the process but unsure of the kernel values.
1 个评论
Rik
2021-1-11
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.
回答(1 个)
Steve Eddins
2021-1-11
Convolution is associative:
![Associativity of convolution](https://www.mathworks.com/matlabcentral/answers/uploaded_files/484833/image.png)
So, your 7x7 convolution kernel would be the convolution of the mean filters:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/484838/image.png)
Use the 'full' option of conv2 to do this.
Note: I wouldn't necessarily expect convolving once with 7x7 to be faster than convolving three times with 3x3 filters. Convolving with a 7x7 filter is 49 multiplications and adds per pixel, whereas convolving three times with 3x3 filters is 3 times 9 = 27 multiplications and adds per pixel.
There is some overhead (such as memory allocation and input processing) associated with each convolution operation, so execution time is not just about counting floating-point operations. Generally, though, decomposing a larger filter into a sequence of smaller filters is a technique used to speed up operations, not slow them down.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!