Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem scrambling a picture- only grayscale

Status
Not open for further replies.

fibonacci1984

Bioengineer
Mar 30, 2009
1
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
 
Replies continue below

Recommended for you

I've not done this in Matlab, but it's pretty easy with ImageMagick.
For example, I can take this picture of my dog,
download.aspx

And scramble it:
Code:
convert test.png -encipher passphrase.txt test2.png
Which produces:
download.aspx

To descramble, simply use:
Code:
convert test2.png -decipher passphrase.txt test3.png
Which gets you back to:
download.aspx

Check out the ImageMagick help page here: You should be able to do the above with a system call from Matlab.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor