Matrix "Zigzag" Reordering

Posted by fbrereto on Stack Overflow See other posts from Stack Overflow or by fbrereto
Published on 2010-06-11T17:41:42Z Indexed on 2010/06/11 17:42 UTC
Read the original article Hit count: 294

Filed under:
|
|
|
|

I have an NxM matrix in Matlab that I would like to reorder in similar fashion to the way JPEG reorders its subblock pixels:

zigzag layout pattern(referenced from here)

I would like the algorithm to be generic such that I can pass in a 2D matrix with any dimensions. I am a C++ programmer by trade and am very tempted to write an old school loop to accomplish this, but I suspect there is a better way to do it in Matlab.

© Stack Overflow or respective owner

Related posts about c++

Related posts about matlab