if i have 256x256 matrix and i want to zero padding it to 512x512 how can i do ?

조회 수: 4 (최근 30일)
I have file name k_im which has 256x256 matrix and i want to do zero padding it to matrix 512x512 help me write a code pls tyvm.

답변 (2개)

the cyclist
the cyclist 2019년 9월 26일
편집: the cyclist 2019년 9월 26일
If you have the Image Processing Toolbox, you can use padarray.
If not,
paddedM = zeros(512:512);
paddedM(129:384,129:384) = M;
(assuming you want equal padding on all sides, and I did my math right).

James Tursa
James Tursa 2019년 9월 26일
If you just want it padded on two sides, then simply
k_im = your 256x256 matrix
k_im(512,512) = 0; % pad 0's out to (512,512) element

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by