Randomizing the rows of a matrix and reversing

Hello, I have a 988 x 3 matrix (say the vertices of 3D object) and I want to randomize the rows of this matrix and then do the reverse process to get the original matrix. I am using the following code to do the job:
The above code doesn't produce the original matrix. Can someone highlight my mistake and give me a solution?

 Accepted Answer

José-Luis
José-Luis on 1 Aug 2017
Edited: José-Luis on 1 Aug 2017
If you want to return to the original matrix, you need to keep it. There is no way to undo a random permutation, unless your data was ordered/structured in some way (was it?). If it was ordered, how so? The key word is random.
Just to be psychotic about it. randperm() is not random but pseudo-random. If you knew the state of the random number generator, it could be possible to go back to the original. I am guessing this is not what you had in mind.

8 Comments

I think row indices define the order of the data in this case.
Then it's sort of trivial. I believe I misunderstood what you meant. Here's at it:
bla = rand(988,3);
idx = randperm(988);
rand_matrix = bla(idx,:);
original_matrix(idx,:) = rand_matrix;
I have another question. Is it possible to process (addition/subtraction with a scalar, DCT, DWT etc) a specific number of randomly selected rows and then at the receiver side identify those random rows given the seed value of randperm and do the reverse process? Let say I want to add 2 to randomly selected 25 rows out of 988. Then at the receiver side get the same 25 rows and subtract 2 from them. Sorry to bother you again.
Then you need to keep the index of those 25 rows as well and perform the inverse operation in the end.
What I don't understand is why go through all that trouble. It strikes me as much simpler to just keep the original matrix.
Actually, I am a student of reversible data hiding using 3D mesh models. I embed confidential data into a 3D model at the transmitter side, then transmit the marked model. At the receiver side, we have to decode the embedded data and recover the original 3D model. In such application scenarios, we don't keep the original model. All we can share is a secret key such rng data for recovery.
Then you need to pass the two indexes or the state of your random number generator to recreate them.
That being said, this does not feel like the best way of hiding data, but what do I know :)
Thank you so much. This is only to permute the locations for achieving more security. The hiding itself is a complex algorithm and has nothing to do with permutation.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!