zero padding on several images
Afficher commentaires plus anciens
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 commentaires
Turlough Hughes
le 7 Mai 2021
Modifié(e) : Turlough Hughes
le 7 Mai 2021
How do the images appear in your workspace? - 4D Matrix, loaded one at a time, cell array?
forgood2
le 8 Mai 2021
Image Analyst
le 8 Mai 2021
Well that's fine, but what about the answers below???
Réponse acceptée
Plus de réponses (2)
Image Analyst
le 8 Mai 2021
1 vote
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 commentaire
DGM
le 8 Mai 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.
Catégories
En savoir plus sur Image Processing Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!