How I can zero pad a 14*14 matrix to 682*577 dimension?
Show older comments
Hi,
I want to zero pad a matrix with 14*14 dimension to have 682*577 dimensions. I want to data be in center of the new matrix. How I can do it?
I used this
D = padarray(h,[334 281],0,'both');
but I get a matrix with 682*576 dimensions. What's wrong?
3 Comments
Matt J
on 9 May 2021
Maybe h is zero?
mohammad nemat
on 9 May 2021
The dimensions seem fine, since
[334 281]*2+14
And, we can check right here and now that if h is not zero, it works:
D = padarray(ones(14),[334 281],0,'both');
imshow(D)
Accepted Answer
More Answers (1)
Walter Roberson
on 9 May 2021
0 votes
but I get a matrix with 682*576 dimensions. What's wrong?
You started with a matrix with even dimension, 14 x 14. You used padarray() with 'both'. That puts the same amount of space on the left and right, so the number of columns is going to be N + 14 + N = (2*N) + 14 for some integer N. But that is always going to be an even number. Therefore you cannot use padarray() 'both' to turn an array with even dimension into an array with odd dimension in a single step.
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
