Skip to content

This project implements an image encryption technique based on chaotic theory using the logistic map.

Notifications You must be signed in to change notification settings

malik-suhail/Chaotic-based-image-encryption-using-logistic-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chaotic-based Image Encryption Using Logistic Map

This project demonstrates an image encryption technique based on chaotic theory using the logistic map. It scrambles image pixels according to a chaotic sequence, making the image unintelligible without the correct chaotic key.

Original Image

image

Encrypted Image using Logistic map in grayscale

image

Decrypted Image in grayscale

image

Table of Contents

Introduction

Chaotic systems, such as the logistic map, are highly sensitive to initial conditions. In this project, we use the logistic map to generate a chaotic sequence that scrambles and encrypts grayscale images. Decryption requires the same chaotic key used for encryption, providing a high level of security.

Chaotic Theory

Chaotic theory is a branch of mathematics focusing on systems that are highly sensitive to initial conditions, known as the "butterfly effect." Even the smallest change in the starting state of a chaotic system can lead to vastly different outcomes. Chaotic systems appear random and unpredictable but are governed by deterministic rules, making them an attractive tool for encryption, where small changes in the encryption key can drastically alter the result.

Logistic Map

The logistic map is a simple mathematical model that exhibits chaotic behavior. It is defined by the recursive formula:

Formula

The logistic map is given by the recurrence relation:

$$ x_{n+1} = r \cdot x_n \cdot (1 - x_n) $$

Where:

  • ( x_n ) is the population at generation (n), normalized between 0 and 1.
  • ( r ) is the growth rate parameter.
  • ( x_{n+1} ) is the population in the next generation.

For values of (r), the logistic map exhibits various behaviors ranging from steady states to chaotic behavior.

LogisticMap BifurcationDiagram.png
By PAR - Own work, Public Domain, Link

Features

  • Grayscale Image Encryption: By default, the system encrypts grayscale images using pixel scrambling.
  • Chaotic Key: The logistic map generates a chaotic sequence based on initial conditions (r and x0), which acts as the encryption key.
  • Lossless Decryption: The decryption process accurately restores the original image using the chaotic key.

How It Works

  1. Image Loading: The input image is loaded and converted to grayscale (if necessary).
  2. Logistic Map Generation: A chaotic sequence is generated using the logistic map formula.
  3. Pixel Scrambling: The image pixels are scrambled according to the chaotic sequence to produce the encrypted image.
  4. Decryption: To decrypt, the same chaotic sequence is used to reverse the pixel scrambling, restoring the original image.

Prerequisites

Before running the code, you need to install the following Python libraries:

  • Pillow (for image processing)
  • NumPy (for numerical operations)
  • Matplotlib (for visualization)

Usage

Load image and generate a chaotic sequence

Load an image by proving the path of the image to the image_path variable in the encrypt file. image_path = "image.jpg"

Generate chaotic sequence based on initial conditions (r and x0)

r = 3.99 # Control parameter

x0 = 0.5 # Initial condition

Decrypt an Image

To decrypt the image, you use the same chaotic key (sequence) used during encryption.

Load the encrypted image

image_path = "encrypted_image.png" # Path to the input image

Customizing for RGB Images

By default, the project handles grayscale images. To extend it for RGB images, each color channel (Red, Green, Blue) should be encrypted individually:

  1. Split the image into R, G, and B channels.
  2. Apply the chaotic encryption to each channel separately.
  3. Merge the channels back together to form the encrypted RGB image.

This can be implemented with small modifications to the existing code.

Future Enhancements

  • Extend the project to support RGB image encryption.
  • Explore other chaotic systems like the Henon map or Lorenz system for stronger encryption.
  • Add an interface for customizing chaotic parameters (`r` and `x0`).

About

This project implements an image encryption technique based on chaotic theory using the logistic map.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published