Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

how to split and store it into one arrray?

1 visualizzazione (ultimi 30 giorni)
Tia
Tia il 15 Lug 2013
Chiuso: MATLAB Answer Bot il 20 Ago 2021
hello.. i'm trying to split image into block 8x8, then extract the pixel values from each block. i want to move position of blocks. then store it back into 1 array..how do i get it?sorry, i am newbie thanks

Risposte (1)

David Sanchez
David Sanchez il 15 Lug 2013
I = your_image;
[rows,cols] = size(I); % dimensions of your image
M = cell(8,8);
for k=1:8
for l = 1:8
M{k,l} = I( (rows*(k-1)/8 + 1):(rows*k/8) , (cols*(l-1)/8 +1):(cols*l/8) );
M{k,l} = reshape8M{k,l},(rows*cols/64),1); % reshape into single column
end
end
  2 Commenti
David Sanchez
David Sanchez il 15 Lug 2013
here with the typo in the 7th line corrected:
I = your_image;
[rows,cols] = size(I); % dimensions of your image
for k=1:8
for l = 1:8
M{k,l} = I( (rows*(k-1)/8 + 1):(rows*k/8) , (cols*(l-1)/8 +1):(cols*l/8) );
M{k,l} = reshape(M{k,l},(rows*cols/64),1); % reshape into single column
end
end
Jan
Jan il 15 Lug 2013
@David: You can edit your question instead of adding a comment with a corrected version.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by