How to get Original image from the shuffled image without using any previous variables?

1 visualizzazione (ultimi 30 giorni)
close all;
clear all;
clc;
%%Read Image
img = imread('Baboon.bmp');
figure;
imshow(uint8(img)); title('Plain Image')
%%Shuffle Image
[m, n] = size(img);
[~, idx] = sort(rand(m,n));
SImg = img(sub2ind([m, n], idx, ones(m,1)*(1:n)))
figure;
imshow(uint8(SImg)); title('Shuffle Image');
imwrite(SImg,'Shuffle.bmp');
%%Reshuffle
img2 = imread('Shuffle.bmp');
[m, n] = size(img2);
[~, rdx] = sort(idx); %%
RsImg = img2(sub2ind([m, n], rdx, ones(m,1)*(1:n)));
figure;
imshow(uint8(RsImg)); title('Reshuffle');

Risposte (1)

Walter Roberson
Walter Roberson il 10 Dic 2022
Modificato: Walter Roberson il 10 Dic 2022
You cannot do that.
Suppose that you have an image which is a simple off-center box inside background. Suppose the random sorting you do just happens to be the exact reverse of the original order, so that the "shuffled" image happens to be the same as the original image but flipped upside-down. Unless you have detailed external information about the content of the image, there is nothing in the flipped image that would allow you to tell that it is not an original image.
For example you might hypthosize that perhaps you could do some kind of fourier transform of the shuffled image and notice that the fourier pattern is "wrong" and "somehow" restore the pattern and invert to get the original image. But the fourier transform of the upside down version of an image is going to have the same frequency patterns as the original image, just perhaps with a different phase. Unless the input images are highly restricted, there is no possibility of figuring out which of the two is the original.
Now... if you knew the random number generator for the rand() call, then in the decoding you could rand() again to find the shuffle pattern, and "invert" that pattern to restore the original image. But that requires either using a constant random number seed, or else keeping at least the random number seed information in a variable.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by