필터 지우기
필터 지우기

How to perform reverse permute to an already permuted matrix?

조회 수: 6 (최근 30일)
Abirami
Abirami 2015년 4월 21일
댓글: Vivek Chaudhary 2019년 3월 12일
Hello, I have taken a color image as input and separated out the R G and B components. And then I converted the three planes into 1 D vectors. Consider a 4x4x3 matrix.The planes are interleaved as follows
V=[r1g1b1....r6]
W=[g6b6r7...g11]
X=[b11r12...b16]
The following is the code that I used to permute the three planes.
A=imread('C:\Users\Desktop\lena.jpg');
R = A(:, :, 1);
G = A(:, :, 2);
B = A(:, :, 3);
R1 = reshape(R.',1,[]);
G1 = reshape(G.',1,[]);
B1 = reshape(B.',1,[]);
H = permute(A, [3 1 2]);
N = numel(A)/3;
V = H(1 : N);
W = H(N + 1 : 2*N);
X = H(2*N + 1 : end);
Now I need to reverse this function ie; de-interleave the vectors and separate out the three planes and then combine them to get the original image. I dont know how to perform the inverse. I used ipermute function as follows, but i'm not able to obtain a proper result.I have obtained S,T and U which are equal to V,W and X. Dimg is equal to H.
C = ipermute(Dimg, [3 1 2])
Please help.Thanks in advance.
  댓글 수: 2
David Sanchez
David Sanchez 2015년 4월 21일
Who is Dimg?
Did you try:
C = ipermute(H,[3 1 2]);
?
Vivek Chaudhary
Vivek Chaudhary 2019년 3월 12일
clc;
%% this program can permute any length vector (row vector)
A=[1 2 3 4 5 6 7 8 9]
M=length(A);
index=randperm(M); %% index
%% permutation
for i=1:M
B(:,i)=A(:,index(i));
z(:,index(i))=i; %% inverse mapping index
end
%% inverse mapping
for j=1:M
A_hat(:,j)=B(:,z(j));
end
A_hat

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by