4 views (last 30 days)
Anjali Sharma on 5 Aug 2020
Commented: Anjali Sharma on 5 Aug 2020
I have to do image processing. I have one data with 100 x 100 matrix and another with 300 x 300 matrix. I want to add zeros to 100 x100 matrix to equalize it like 300 x300 but zeros to be added after 100 x 100 equally and not in particular end.

Bruno Luong on 5 Aug 2020
% Replace this with your image
Image100 = peaks(100)+10;

KSSV on 5 Aug 2020
Edited: KSSV on 5 Aug 2020
Let A be your 100*100 matrix.
B = zeros(300) ;
B(1:100,1:100) = A ;

Anjali Sharma on 5 Aug 2020
This yield a matrix with zeros added at the end of my data matrix.
Suppose A =
1 2
3 4
I want zeros to be added like this
A =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 2 0 0
0 0 3 4 0 0
0 0 0 0 0 0
0 0 0 0 0 0
equally all aorund. The data should lie in between zeros.
Can you pls suggest anything here.
KSSV on 5 Aug 2020
A = rand(2) ;
[m,n] = size(A) ;
B = zeros(3*m,3*n) ;
B((m+1):2*m,(n+1):2*n) = A ;
Anjali Sharma on 5 Aug 2020
Yes this worked..!!!
Thank you.
Unfortunately I dont have Image toolbox so cant use padarray otherwise it could be easy.