Random shuffle of image pixels/ Image scrambling

27 vues (au cours des 30 derniers jours)
marie lasz
marie lasz le 8 Sep 2020
Commenté : marie lasz le 28 Déc 2020
hello,
I am applying arnold transform method on an image to scramble its pixels. And i am doing it successfully but the problem in this method is that first I have to binarize the image before applying this method and that is why I am getting binarized image in a result in inverse of arnold transform. So, my question is that is there any other method in which I scramble or shuffle pixels by setting a key value without binarizing the image? so that I would be able to revert the image back ?
thank you very much :-)

Réponses (1)

Sindar
Sindar le 9 Sep 2020
You can use randperm to shuffle the indices randomly, then sort to get the indices for reversing it:
% load in an image included in Matlab
corn_gray = imread('corn.tif',3);
% get the size
imsize = size(corn_gray);
% display
imshow(corn_gray)
% create a randomly-shuffled list of linear indices 1:total pixels
idx_shuffle=randperm(numel(corn_gray));
% get the inverse (idx_shuffle(idx_unshuffle) = 1:total pixels)
[~,idx_unshuffle] = sort(idx_shuffle);
% put the indices into the same row-col shape as the image
idx_shuffle = reshape(idx_shuffle,imsize);
idx_unshuffle = reshape(idx_unshuffle,imsize);
% compute the shuffled image
corn_gray_shuffled = corn_gray(idx_shuffle);
% run an arbitrary transformation on it
corn_gray_shuffled = corn_gray_shuffled.^2;
% display the shuffled, transformed image
imshow(corn_gray_shuffled)
% unshuffle the transformed image
corn_gray_unshuffled = corn_gray_shuffled(idx_unshuffle);
% and display
imshow(corn_gray_unshuffled)
  4 commentaires
Faizan Ahmed Khan
Faizan Ahmed Khan le 28 Déc 2020
@marie lasz did you find how we can do this ?
marie lasz
marie lasz le 28 Déc 2020
@Faizan, No I didn't. But I am working with Arnold.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by