# SecureVision: An Open-Source User-Customizable Image Encryption Program
## Materials and Methods
### Random Shuffling of Pixel Positions  
The positions of pixels in an image were randomly shuffled using the random number generator from our model. The width (\(w\)) and height (\(h\)) of the image were determined from the image file, which was in a greyscale pgm format at the current stage. The random pixel shuffling scheme is shown schematically in Figure 4.  
The random numbers generated from our model and the standard FORTRAN90 routine were floating-point numbers between 0 and 1. Our main goal here was to shuffle the pixels along both long and short edges of the image, so two columnar arrays for random width and height positions should be generated by way of floating-point random numbers (between 0 and 1) generated by the model. A 2-dimensional array named \"INP\" was created with the pixel components of the original image, INP(\(i\),\(j\)), as input elements, where \(i\) and \(j\) are width and height positions of the original image. The generated random numbers were used to shuffle the elements in INP to create a new array. It is remarked here that conversion of floating-point random numbers to integers for the width and height positions of the image could cause overlaps in the shuffled pixel positions. This issue will be discussed and tackled in later parts of the present paper. Shuffling of pixel positions would in effect hide the features in an image and therefore encrypt it. An example is shown in Figure 5, where the original image has been encrypted only by way of shuffling the pixel positions. The corresponding histograms showing the distribution of greyscale values of the pixels are also shown, in which the \(x\)-axis represents greyscale values ranging from 0 (black) to 255 (white). The features in the original image could no longer be identified upon random shuffling of pixel positions, and could only be restored upon decryption using the set of keys employed for the encryption. The random number generator from our model handled the decryption and generated the same set of random numbers for the same set of keys. The possibility of a brute-force attack to decipher the private keys by an unauthorized user would be reduced by employing longer keys during encryption, which would in turn enhance the security of the encrypted images.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \(p\)**-Value** & **0.0001–0.001** & **0.001–0.01** & **0.01–0.1** & **0.1–1.0** \\ \hline Count & 7 & 83 & 904 & 8932 \\ \hline Results & Non-random & Non-random & Random & Random \\ \hline \hline \end{tabular}
\end{table}
Table 1: Results from the frequency (monobit) randomness test.  
Figure 4: Schematic diagram showing random shuffling of pixel positions using the random number generator from our model.  
A descriptive algorithm that describes part of the encryption method employed in the present work is shown below, Algorithm 1.  
```
1. Initialize the variables.
2. Read image size, width (\(w\)) and height (\(l\)).
3. Read the private keys: \(x\), \(a\), \(b\) (see Equation (1)), _deno_, _izmax_, _delta_, A (see Equation (3)).
4. Allocate 2 \(\times\) 2 array, INPC.
5. Read image components into INP.
6. Calculate the \(y\)-coordinate of ellipse based on private keys
7. Calculate modulo of the \(y\)-coordinate, _deno_.
8. Multiply the \(y\) value with the remainder of the division
9. Calculate the positive decimal value from step 8, obtain random number (\(z\)).
10. allocate two 2 \(\times\) 2 arrays containing horizontal (pw) and vertical (ph) image coordinates
11. convert \(z\) into image coordinates and read into pw and ph.
12. Allocate 2 \(\times\) 2 array, INPC.
13. shuffle the image pixels based on pw and ph.
14. store the shuffled pixel values in INPC array.
15. write out INPC into an image file.
16. _deno_ + _delta_, then \(n=n+1\).
17. if (\(n<izmax\)), go to step 6, if (\(n>izmax\)), then terminate, maximum iterations (\(izmax\)) reached.
```  
**Algorithm 1** Random Pixel Shuffling