Open In App
Related Articles

Image encryption using cellular automata

Like Article
Save Article
Report issue
To propose an image encryption system using one dimensional cellular automata for image encryption and decryption. Cellular automata can be corresponded with the essential cryptographic properties i.e. Balance, correlation-immune, nonlinearity, easy to implement in hardware. CA cryptosystems can give better performances compared to classic methods that are based on computational techniques. Therefore, this technique should be most favourable for cryptography. Features: 1. Encryption –
  • RGB: Extract individual RGB channel to encrypt each layer and merge.
  • Gray: Convert the given image to grayscale and use it for encryption.
2. Decryption –
  • Key: Use a key for each pixel for decryption process stored in a separate file.
  • Preset: Use predefined rules to decrypt the image.
3. Result and Analysis –
  • Histogram: Histogram analysis is defined as the frequency of the image pixels in graphical representation.
  • Correlation: Correlation is a statistical measure that indicates the extent to which two or more variables fluctuate together.
4. Rule Selection – Rules to be applied to encrypt image can be selected and order can be changed (R30, R90, R120).Further rules can also be added. Implementation/Algorithms:
  • Encryption – Converting image to 2d matrix and modifying each pixel value by using key function.
    1. Grayscale image is taken as input.
    2. Image is converted to a 2D matrix (M).
    3. Execute M1=Key (M), where M1 is the encrypted 2D matrix.
    4. Each pixel values of M matrix is modified by using the Key function h1(M) depending on whether the value of the pixel sent is odd or even which is stored in a separate index file INF for each pixel.
    5. The modified pixel is then received and stored in M1.
    6. Matrix M1 is converted to image and saved as an encrypted image.

  • Decryption – Original pixels are retrieved by using the reverse technique
    1. Encrypted image is taken as an input
    2. Image is converted to a 2D matrix(M1).
    3. M=Key(M1) is executed, where M is the decrypted 2D matrix.
    4. Each pixel values of M1 matrix is modified by using the Key function h1(M) using its corresponding odd/even rule from index file INF.
    5. The modified pixel is then received and stored in M1.
    6. The M matrix is converted to image and saved as decrypted image.

  • Key Function – Here a 2D matrix is taken as an input and this key () function is called during encryption as well as decryption which modifies the input pixel value using cellular automata rule vector.
    1. The input pixel is converted into binary number of 8 blocks.
    2. Distinct cellular automata rules are applied per block.
    3. If input value is even, rule 90 and 30 are applied alternatively.
    4. If input value is odd, rule 90 is applied.
    5. The rule configuration is run till the initial input block repeats itself.
    6. Recursion stage is noted and half of that cycle is calculated hc = n/2.
    7. The rules are run once again but this time for half the cycle (hc).
    8. Final output of the array is converted back to decimal number and placed in the encrypted /decrypted value of the input block.
    9. Step 1 to step 7 is repeated until all the grayscale values are encrypted /decrypted.
Tools: This image encryption system has been prepared on Python and MATLAB. Following libraries are used:
OpenCV: To extract image pixels and modify it.
Numpy: To make use of arrays in key function.
Matplotlib: To obtain results (histogram, correlation) 
Following Cellular Automata rules have been applied:
Rule 90
Rule 30
Rule 120 
The whole program is divided into modules:
Encryption Script
Decryption Script
Result and Analysis 
Application – Image encryption is the primary task of the program I developed although the system proposed is not only limited to Image encryption. The system can be modified to achieve:
  1. Coding messages
  2. Picture compression
  3. Production of pseudo-random numbers.
Project Link:

Last Updated : 24 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Similar Reads