zero padding on several images
Mostrar comentarios más antiguos
Hello,
I have several images with several sizes (155x75x3,512x74x3...) and I want to do a zero-padding that all images have the same size in order to colvolute them with a 3x3 filter. I know padarray() but I dont know how to do that all images will have the same size at the end.
Any help would be great!
3 comentarios
Turlough Hughes
el 7 de Mayo de 2021
Editada: Turlough Hughes
el 7 de Mayo de 2021
How do the images appear in your workspace? - 4D Matrix, loaded one at a time, cell array?
forgood2
el 8 de Mayo de 2021
Image Analyst
el 8 de Mayo de 2021
Well that's fine, but what about the answers below???
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 8 de Mayo de 2021
1 voto
Why not simply use imfilter() and not worry about resizing? There are several edge handling options with imfilter() -- more than with conv2().
if you want to use padarray, then use something like
currSize=size(currImg);
paddedImg=padarray(currImg,(aimSize-currSize)/2);
Watch out for differences in size that are not dividable by 2
1 comentario
DGM
el 8 de Mayo de 2021
This is part of why I don't like dealing with padarray
currSize=size(currImg);
paddedImg=padarray(currImg,floor((aimSize-currSize)/2),0,'pre');
paddedImg=padarray(paddedImg,ceil((aimSize-currSize)/2),0,'post');
Most practical uses tend to require repeated calls for something so simple.
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!