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

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

2 Kommentare

Could you give a small example?
for example
1 2 4
2 5 6
1 3 8
to move the diagonal in one pixel like
8 6 4
3 1 2
1 2 5
and give detail about m*n matrix

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 12 Sep. 2012
Bearbeitet: Andrei Bobrov am 12 Sep. 2012
I = [1 2 4
2 5 6
1 3 8 ];
ii = 1:size(I,1)+1:numel(I);
I(ii) = I(ii(mod(ii - 2,3)+1));
or
I(eye(size(I))>0) = circshift(diag(I),1);

1 Kommentar

ajith
ajith am 12 Sep. 2012
Bearbeitet: ajith am 13 Sep. 2012
Thanks a lot sir but i changed the question right now all the elements should change in the diagonal direction for m*n matrix

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Sean de Wolski
Sean de Wolski am 11 Sep. 2012
or diag()?

3 Kommentare

OK, why does your dog have a vest? Just wondering....
Sean de Wolski
Sean de Wolski am 12 Sep. 2012
Bearbeitet: Sean de Wolski am 12 Sep. 2012
So she's not a deer during hunting season :)
Ah - I thought she was like a rescue dog, locating and pulling people from rubble after earthquakes.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by