Skip to content

Instantly share code, notes, and snippets.

@iR00i
Created May 9, 2020 23:09
Show Gist options
  • Save iR00i/a3e37c89d029083dddb129d852a4a28e to your computer and use it in GitHub Desktop.
Save iR00i/a3e37c89d029083dddb129d852a4a28e to your computer and use it in GitHub Desktop.
function [] = reveal(key)
tree = imread('result.png');
r = tree(:,:,1);
g = tree(:,:,2);
b = tree(:,:,3);
%cat = mod(tree,4);%get the least significant 2 bits from each pixel color component.
%cat = cat * 64;%move the least significant 2 bits to the most significant bits
cat(:,:,1) = getimg(r,key);
cat(:,:,2) = getimg(g,key);
cat(:,:,3) = getimg(b,key);
x = getimg(r,key);
imwrite(cat,'cat_revealed.png');
end
function [img] = getimg(image,key)
[row,col] = size(image);
treeVec = image(:);
catVec = treeVec;
max = size(treeVec,1);
i =1;
n = 1;
temp = 2;
disp(treeVec);
while i < max
catVec(i) = mod(treeVec(n),4);
n = n + key;
if n>max
n = temp;
temp = temp + 1;
end
i = i+1;
end
catVec = catVec*64;
img = reshape(catVec,[200,200]);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment