Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

problem scrambling a picture- only grayscale

problem scrambling a picture- only grayscale

problem scrambling a picture- only grayscale


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) = ...

RE: problem scrambling a picture- only grayscale

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

And scramble it:

CODE --> ImageMagick

convert test.png -encipher passphrase.txt test2.png 
Which produces:

To descramble, simply use:

CODE --> ImageMagick

convert test2.png -decipher passphrase.txt test3.png 
Which gets you back to:

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close