MATLAB Answers

M@lik Ali

Copy pixels from one Matrix to other matrix

Asked by M@lik Ali
on 26 Jul 2012

Hi all I have an image of size 256x384x3 then i divide the image into 4x4 blocks as

ca = mat2cell(rgbImage,bs*ones(1,size(rgbImage,1)/bs),bs*ones(1,size(rgbImage,2)/bs),3;
plotIndex = 1;
after that i generate a zero matrix of the image size and divide into blocks as
aa = mat2cell(a,bs*ones(1,size(a,1)/bs),bs*ones(1,size(a,2)/bs),3);
plotIndex = 1;

Now What i want is to copy the few block from original image to the block of matrix a

I tried this


but fail. after copy blocks i want to reconstruct the a matrix. please help me how i can copy the selected block of original image into the block of the new matrix and then reconstruct the a which was my zero matrix

or if there is an other way that how i can copy the block of the original image into zero image.

thanks in Advance.




No products are associated with this question.

1 Answer

Answer by Andrei Bobrov
on 26 Jul 2012
Edited by Andrei Bobrov
on 26 Jul 2012
 Accepted answer

EDIT (block with size 64x64)

rgbImage = imread('861.jpg');
ca = mat2cell(rgbImage,bs*ones(1,size(rgbImage,1)/bs),bs*ones(1,size(rgbImage,2)/bs),3);
plotIndex = 1;
aa = mat2cell(a,bs*ones(1,size(a,1)/bs),bs*ones(1,size(a,2)/bs),3);
amtx = cell2mat(aa);


M@lik Ali
on 26 Jul 2012

You received the image

Andrei Bobrov
on 26 Jul 2012

answer was correct (see EDIT)

M@lik Ali
on 27 Jul 2012

Thanks its work fine now..

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!