How can i use zero-padding in an image?

47 visualizaciones (últimos 30 días)
Gn Gnk
Gn Gnk el 13 de Oct. de 2020
Comentada: Image Analyst el 13 de Oct. de 2020
Hello ,
I have an image(512x512) and i want to do zero-padding in order to covolute it with a filter .
The problem here is that i dont know how to do that ,meaning that i dont know where the zeros should be (around the image or next to it) and furthermore the size of the zero-padding.
Any help would be valuable.

Respuesta aceptada

Image Analyst
Image Analyst el 13 de Oct. de 2020
There is a built-in function for that. It's called padarray().
  5 comentarios
Gn Gnk
Gn Gnk el 13 de Oct. de 2020
Great ! Thank you a lot.
Image Analyst
Image Analyst el 13 de Oct. de 2020
Manual convolution demo attached.

Iniciar sesión para comentar.

Más respuestas (1)

Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
Editada: Ameer Hamza el 13 de Oct. de 2020
You don't need to do padding yourself. imfilter(): https://www.mathworks.com/help/images/ref/imfilter.html automatically does it based on the option you pass
filtered_image = imfilter(img, fil, 'same')
If you want to understand the concept behind it, then this link might be helpful: https://machinelearningmastery.com/padding-and-stride-for-convolutional-neural-networks/
  1 comentario
Gn Gnk
Gn Gnk el 13 de Oct. de 2020
Thank you for your quick response . I am familiar with imfilter() but i actually want to do this process by myself , thats why i am really confused.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by