Scrambling an Image Using Fourier Method


(1) Download these three files: scramble_batch.m , scrambleimg.m, and getimgtype.m .

 

(2) Place the three files that you downloaded in step (1) in a directory that is listed in your MATLABPATH. To see your MATLABPATH, either type

 

echo $MATLABPATH

 

when you're in a tcsh or csh shell, or type

 

path

 

when you're in MATLAB. To learn more about this, type

 

help matlabpath

 

in MATLAB. You can manage your MATLABPATH using the setenv command in your .cshrc file; you can learn more about this command by typing

 

man setenv

 

at the tcsh or csh prompt.

 

(3) Under Linux, place the images that you want to scramble in one directory. For the sake of illustration, let's assume that this directory is /export/w/tmp/junk. Images must be in JPEG, TIFF, GIF, or Analyze format. I'd suggest using JPEG format.

 

(4) Create a plain text file that contains a list of the images to be scrambled. You can do this very easily in the tcsh or csh shell with a command like this example:

 

ls /export/w/tmp/junk/*.jpg > list.txt

 

where ">" is the file redirection operator. This command creates a new text file named list.txt that contains a list of files that end with .jpg in their name, which are presumably JPEG files in this example.

 

(5) Invoke MATLAB in the same directory where you have the text file containing the list of file names, and at the MATLAB prompt type

 

scramble_batch

 

If you get an error

 

??? Undefined function or variable 'scramble_batch'.

 

it means that MATLAB doesn't know where to find this script. You need to place this script in a directory that is listed in your MATLABPATH. Go back to step (2) and obtain help if necessary.

 

(6) You will be prompted for the name of the text file created in step (4). Type in the name of that file, followed by a carriage return, e.g.

 

list.txt

 

(7) You will be asked to choose what sort of format you'd like the output in. Again, I'd go with JPEG (type in "1", followed by a carriage return).

 

(8) Scrambled versions of the images will be created in the same directory in which the original images were kept. They will have the same names as the originals, but with scrambled_ prepended to the name. Note: this script was written for gray-scale images, not color images (I think it was originally written for this study). This script seems to introduce new colors when scrambling color images, which is probably undesirable (perhaps it is okay?). So, I wouldn't recommend using this with color pictures.