How to prevent conv2d from changing image size

14 次查看(过去 30 天)
I have an image of size 330x363 uint8. I am convoluting it with 11x11 filter using conv2. The resulting image gets padded with zeros from top (6 pixels), bottom (4 pixels), left (6 pixels), right (4 pixels). Is there a way to prevent this padding from happening? Is it a good practice to crop the resulting image after the convolution?

采纳的回答

Walter Roberson
Walter Roberson 2019-4-22
编辑:Walter Roberson 2019-4-22
conv2(A, B, 'same') or conv2(A, B, 'valid')
  1 个评论
Nour Aburaed
Nour Aburaed 2019-4-22
I've already tried 'same' before but it did not work, as it also introduced zero padding of size 1. But 'valid' worked just fine! Thank you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by