Need help to scramble unscramble gray scale image based on Affine Transformation
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am trying gray scale image affine transformation but after doing scramble, unscramble is not happening. PFB the source code. Need help urgently please.
% To read rgb image and covert that to gray scale 128*128
a = imread('C:/Matlab/image1.jpg');
b = rgb2gray(a);
c = imresize(b,[128,128]);
imwrite(c,'C:/Matlab/resized.jpg');
inImg = double(imread('C:/Matlab/resized.jpg'));
%s = size(inImg);
%enImg = ones(s);
img = inImg(:,:,1);
[i, j] = size(img);
%subplot(1,4,1);
%imshow(img);
%To scramble
[y, x] = ndgrid(1:size(img, 1), 1:size(img, 2)); %order is [y, x] or [row, column]
f1 = floor((3 + 13 * x) / 128);
x1 = mod(3 + 13 * x, 128);
f2 = floor((5 + 7 * y) / 128);
y1 = mod(5 + 7 * y, 128);
scrambledimage = img(sub2ind(size(img), y1+1, x1+1));
%subplot(1,4,2);
%imshow(scrambledimage);
imwrite(scrambledimage,'C:/Matlab/scrambledimage.jpg');
%To unscramble
newx = mod(((x1 + (f1 * 128)) - 3) / 13, 129);
newy = mod(((y1 + (f2 * 128)) - 5) / 7, 129);
for k = 1 : numel(newx)
newRow = round(newy(k));
newCol = round(newx(k));
%enImg(newRow, newCol) = scrambledimage(y1(k)+1, x1(k)+1);
enImg(newRow, newCol) = scrambledimage(sub2ind(size(scrambledimage), y1(k)+1, x1(k)+1));
end
%subplot(1,4,3);
%imshow(newR);
imwrite(enImg,'C:/Matlab/unscrambledimage.jpg');
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!