zero padding on several images
古いコメントを表示
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 件のコメント
Turlough Hughes
2021 年 5 月 7 日
編集済み: Turlough Hughes
2021 年 5 月 7 日
How do the images appear in your workspace? - 4D Matrix, loaded one at a time, cell array?
forgood2
2021 年 5 月 8 日
Image Analyst
2021 年 5 月 8 日
Well that's fine, but what about the answers below???
採用された回答
その他の回答 (2 件)
Image Analyst
2021 年 5 月 8 日
1 投票
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 件のコメント
DGM
2021 年 5 月 8 日
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.
カテゴリ
ヘルプ センター および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!