필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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');

답변 (1개)

Walter Roberson
Walter Roberson 2022년 12월 10일
편집: Walter Roberson 2022년 12월 10일
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.

카테고리

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