×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

# 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

### 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.

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!