Borrar filtros
Borrar filtros

HOW TO MOVE THE DIAGONAL ELEMENTS IN MATRIX (ONE PIXELS) FOR IMAGE PROCESSING

4 visualizaciones (últimos 30 días)
how to move the array
1 4 6
8 2 3
7 9 5
all elements are move diagonally one pixel for m*n matix
  3 comentarios
Walter Roberson
Walter Roberson el 13 de Sept. de 2012
Please show an example input and example output.
ajith
ajith el 13 de Sept. de 2012
Editada: ajith el 13 de Sept. de 2012
example output
2 3 6
9 5 4
7 8 1

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 13 de Sept. de 2012
I = [
1 4 6
8 2 3
7 9 5]; % initial array
idx = reshape(1:numel(I),size(I));
for jj = -size(I,1) + 2 : size(I,2) - 2
a = diag(idx,jj);
I(a) = I(circshift(a,1));
end

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by