problem scrambling a picture- only grayscale
problem scrambling a picture- only grayscale
(OP)
Hi,
I would like to modify a full colored picture making it scrambled.
My problem is that matlab gives me a gray scale picture when I enter a full colored picture.
Here is the function.... hope somebody can help me
function newim = scrambled(im,n)
mn = floor(size(im)/n);
m1 = mn(1);
n1 = mn(2);
newim = zeros(m1*n,n1*n);
ind = randperm(m1*n1);
[ind1,ind2] = ind2sub([m1,n1],ind);
for k = 1:m1*n1
[i,j] = ind2sub([m1,n1],k);
newim((i-1)*n+1:i*n,(j-1)*n+1:j*n) = ...
im((ind1(k)-1)*n+1:ind1(k)*n,(ind2(k)-1)*n+1:ind2(k)*n);
end
I would like to modify a full colored picture making it scrambled.
My problem is that matlab gives me a gray scale picture when I enter a full colored picture.
Here is the function.... hope somebody can help me
function newim = scrambled(im,n)
mn = floor(size(im)/n);
m1 = mn(1);
n1 = mn(2);
newim = zeros(m1*n,n1*n);
ind = randperm(m1*n1);
[ind1,ind2] = ind2sub([m1,n1],ind);
for k = 1:m1*n1
[i,j] = ind2sub([m1,n1],k);
newim((i-1)*n+1:i*n,(j-1)*n+1:j*n) = ...
im((ind1(k)-1)*n+1:ind1(k)*n,(ind2(k)-1)*n+1:ind2(k)*n);
end
RE: problem scrambling a picture- only grayscale
For example, I can take this picture of my dog,
And scramble it:
CODE --> ImageMagick
To descramble, simply use:
CODE --> ImageMagick
Check out the ImageMagick help page here: http://www.imagemagick.org/script/cipher.php
You should be able to do the above with a system call from Matlab.