Copy pixels from one Matrix to other matrix

Hi all I have an image of size 256x384x3 then i divide the image into 4x4 blocks as
bs=4;
alp=0;
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
a=zeros(size(rgbImage));
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
aa{37,88}=ca{37,88}
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.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
Editada: Andrei Bobrov el 26 de Jul. de 2012
EDIT (block with size 64x64)
rgbImage = imread('861.jpg');
bs=64;
ca = mat2cell(rgbImage,bs*ones(1,size(rgbImage,1)/bs),bs*ones(1,size(rgbImage,2)/bs),3);
plotIndex = 1;
a=zeros(size(rgbImage),class(rgbImage));
aa = mat2cell(a,bs*ones(1,size(a,1)/bs),bs*ones(1,size(a,2)/bs),3);
aa(2,3)=ca(2,3);
amtx = cell2mat(aa);
imshow(amtx)

12 comentarios

M@lik Ali
M@lik Ali el 26 de Jul. de 2012
Thanks Andrei Bobrov for reply but when i run this command fallowing error occur.
Cell contents reference from a non-cell array object.
Error in ==> cell2mat at 44 cellclass = class(c{1});
Error in ==> segmen at 146 amtx = cell2mat(a);
M@lik Ali
M@lik Ali el 26 de Jul. de 2012
how to reconstruct the new image from a selected region or selected blocks only.
Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
Answer was corrected
M@lik Ali
M@lik Ali el 26 de Jul. de 2012
andrei Thanks but Still the error is there Cell contents reference from a non-cell array object.
Error in ==> cell2mat at 44 cellclass = class(c{1});
Error in ==> segmen at 272 amtx = cell2mat(a);
Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
Answer was corrected
M@lik Ali
M@lik Ali el 26 de Jul. de 2012
Yes I tried the corrected answer but still the problem is there.
Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
Give your image
M@lik Ali
M@lik Ali el 26 de Jul. de 2012
ok I email you the image at abobroff@mail.ru i don't know how to upload here
Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
Hi Muhammad!
First: your image and my answer was correct.
M@lik Ali
M@lik Ali el 26 de Jul. de 2012
You received the image
Andrei Bobrov
Andrei Bobrov el 26 de Jul. de 2012
answer was correct (see EDIT)
M@lik Ali
M@lik Ali el 27 de Jul. de 2012
Thanks its work fine now..

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by