extract matrix from matrix

sir i have image of size 256*256 and i want to extract 5*5 matrix from every 8*8 block of 256*256 image what is code for this...also i want to add zeros to all 5*5 blocks and make 5*5 to 8*8 matrix of the 256*256 image ..what is code for this

1 comentario

the cyclist
the cyclist el 12 de Abr. de 2014
For your second question, how are the 5x5 blocks stored, specifically?

Iniciar sesión para comentar.

Respuestas (1)

the cyclist
the cyclist el 11 de Abr. de 2014

0 votos

Here is a very straightforward way to do this:
% Put in some pretend data
bigMatrix = rand(256);
% The algorithm
for ni=1:8:256
for nj = 1:8:256
i_idx = (ni-1)/8+1;
j_idx = (nj-1)/8+1;
smallMatrices{i_idx,j_idx} = bigMatrix(ni:ni+7,nj:nj+7);
smallMatrices{i_idx,j_idx}(:,6:8) = 0;
smallMatrices{i_idx,j_idx}(6:8,:) = 0;
end
end

4 comentarios

Jitesh Bhanushali
Jitesh Bhanushali el 11 de Abr. de 2014
sir i want 2 different code for that
the cyclist
the cyclist el 12 de Abr. de 2014
If you remove the lines where I set the rows/columns to zero, then it solves your first issue.
Jitesh Bhanushali
Jitesh Bhanushali el 24 de Abr. de 2014
sir how to solve second issue
the cyclist
the cyclist el 25 de Abr. de 2014
I can't help you solve the second issue until you respond to the comment I made (just under your question). How are the 5x5 blocks stored?

Iniciar sesión para comentar.

Preguntada:

el 11 de Abr. de 2014

Comentada:

el 25 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by