Matrix “Zigzag” Reordering

后端 未结 6 1507
名媛妹妹
名媛妹妹 2020-11-30 04:35

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

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 05:14

    Let's assume for a moment that you have a 2-D matrix that's the same size as your image specifying the correct index. Call this array idx; then the matlab commands to reorder your image would be

    [~,I] = sort (idx(:)); %sort the 1D indices of the image into ascending order according to idx
    reorderedim = im(I);
    

    I don't see an obvious solution to generate idx without using for loops or recursion, but I'll think some more.

提交回复
热议问题