how to permute matrix here?

Hi.. I have an image 128x128pixels. then it is divided into 8x8 block. so that we get 16 subblocks. each 8x8 block, i would like to permute position(1,1) of matrix 8x8 from one subblock to another subblock with same position (1,1). do you know how to solve this problem? i don't know about permutation here. Thank you

답변 (1개)

Image Analyst
Image Analyst 2013년 3월 31일

0 개 추천

I don't even know what that means. Can you explain better and give an example? Can you also explain why you want to do this?
Otherwise, the only thing I can suggest is to get the row and column of each pixel in each block that you wish to swap and do the usual swap code:
savedPixelValue = grayImage(row1, column1);
grayImage(row1, column1) = grayImage(row2, column2);
grayImage(row2, column2) = savedPixelValue;

댓글 수: 4

Tia
Tia 2013년 3월 31일
example
m=[1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6]
it is divided into 3x3
b=[1 2 3 ; 1 2 3; 1 2 3];
so, we have 4 subblocks
m=[ 1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6]
then, i want to move (1) to (4)
m=[(1)2 3 (4)5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6]
what should i do?sorry make you confused.. i have an assignment. is it right to use permute here?
Image Analyst
Image Analyst 2013년 3월 31일
Is the "b" a 4 by 4 array of blocks? Is it a cell array, or a 3D array of integers or doubles?
Tia
Tia 2013년 3월 31일
b is an array 3x3 from m. then,it become 4subblocks
b1=[ 1 2 3 b2=[4 5 6
1 2 3 4 5 6
1 2 3] 4 5 6]
b3=[1 2 3 b4=[4 5 6
1 2 3 4 5 6
1 2 3] 4 5 6]
it's a 2D array
So why can't you adapt my code as follows:
row1 = 1;
column1 = 1;
savedPixelValue = b1(row1, column1);
b1(row1, column1) = b2(row2, column2);
b2(row2, column2) = savedPixelValue;

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

Tia
2013년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by