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

3 views (last 30 days)
HOW TO MOVE THE DIAGONAL ELEMENTS IN MATRIX (ONE PIXELS) FOR IMAGE PROCESSING

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 12 Sep 2012
Edited: Andrei Bobrov on 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 Comment
ajith
ajith on 12 Sep 2012
Edited: ajith on 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

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 11 Sep 2012
How about using circshift()?

Sean de Wolski
Sean de Wolski on 11 Sep 2012
or diag()?
  3 Comments
Image Analyst
Image Analyst on 12 Sep 2012
Ah - I thought she was like a rescue dog, locating and pulling people from rubble after earthquakes.

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!