zero padding on several images
Mostra commenti meno recenti
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 Commenti
Turlough Hughes
il 7 Mag 2021
Modificato: Turlough Hughes
il 7 Mag 2021
How do the images appear in your workspace? - 4D Matrix, loaded one at a time, cell array?
forgood2
il 8 Mag 2021
Image Analyst
il 8 Mag 2021
Well that's fine, but what about the answers below???
Risposta accettata
Più risposte (2)
Image Analyst
il 8 Mag 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 Commento
DGM
il 8 Mag 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.
Categorie
Scopri di più su Image Processing Toolbox in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!