A comprehensive full-stack application for Image Processing and Cryptography based on CSE281 Lecture Notes.
├── backend/
│ ├── image_processor.py # Core image processing functions
│ ├── app.py # Flask REST API
│ └── requirements.txt # Python dependencies
├── frontend/
│ ├── src/app/page.tsx # Next.js frontend application
│ └── ... # Next.js project files
└── Lecture_*.pdf # CSE281 Lecture notes
- to_grayscale: Convert RGB image to grayscale
- calc_psnr: Calculate Peak Signal-to-Noise Ratio between two images
- calc_correlation: Calculate correlation coefficient between two images
- negative_transform: Image negative (S = 255 - r)
- log_transform: Logarithmic transformation (s = c * ln(1 + r))
- gamma_transform: Power-law/gamma transformation (s = c * r^γ)
- hist_equalization: Histogram equalization for contrast improvement
- binary_segmentation: Binary thresholding
- add_salt_pepper: Add Salt & Pepper noise
- apply_gaussian_filter: Gaussian smoothing filter
- apply_median_filter: Median filter for noise removal
- get_frequency_spectrum: DFT magnitude spectrum visualization
- apply_ideal_lpf: Ideal Low-Pass Filter
- apply_ideal_hpf: Ideal High-Pass Filter
- apply_notch_filter: Notch filter for periodic noise removal
- xor_encrypt_decrypt: XOR-based image encryption/decryption
-
Navigate to the backend directory:
cd backend -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the Flask server:
python app.py
The API will be available at
http://localhost:5000For development with debug mode enabled:
FLASK_DEBUG=true python app.py
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Create
.env.localfile:NEXT_PUBLIC_API_URL=http://localhost:5000 -
Run the development server:
npm run dev
The frontend will be available at
http://localhost:3000
POST /api/to-grayscale- Convert to grayscalePOST /api/calc-psnr- Calculate PSNRPOST /api/calc-correlation- Calculate correlation
POST /api/negative-transform- Apply negative transformPOST /api/log-transform- Apply log transformPOST /api/gamma-transform- Apply gamma transformPOST /api/hist-equalization- Apply histogram equalizationPOST /api/binary-segmentation- Apply binary segmentation
POST /api/add-salt-pepper- Add salt & pepper noisePOST /api/gaussian-filter- Apply Gaussian filterPOST /api/median-filter- Apply median filter
POST /api/frequency-spectrum- Get frequency spectrumPOST /api/ideal-lpf- Apply ideal low-pass filterPOST /api/ideal-hpf- Apply ideal high-pass filterPOST /api/notch-filter- Apply notch filter
POST /api/xor-encrypt- Encrypt with XORPOST /api/xor-decrypt- Decrypt with XORPOST /api/attack-scenario- Run complete attack-decryption scenario
GET /api/docs- Get API documentationGET /api/health- Health check endpoint
The toolkit includes a complete demonstration of the attack-decryption scenario:
- Encrypt: Original image is encrypted using XOR with a secret key
- Attack: Salt & Pepper noise is added to the encrypted image
- Decrypt: The attacked image is decrypted using the same key
- Evaluate: PSNR and correlation metrics measure image quality degradation
All implementations are based on CSE281 Lecture Notes:
- Lecture 4: Image Negatives, Binary Segmentation
- Lecture 5: Grayscale Conversion, Log Transform, Gamma Transform, Histogram Equalization
- Lecture 6: Salt & Pepper Noise, Gaussian Filter, Median Filter
- Lecture 8: DFT, Frequency Filters (LPF, HPF, Notch), XOR Encryption, PSNR, Correlation
Educational use - AIU CSE281 Course Materials