Embark on a daring mission to assist Mechamaru in encoding crucial information about Geto's plan. Meanwhile, Yuji and Megumi must decode the image ensnared by Geto, Jogo, and Mahito holding Gojo in the Prison Realm. Despite the disruptive Gigantic Veil (Tobari) cast by Geto, your mission is to decode the image and thwart Geto's scheme!
๐ค Mechamaru Encoder |
๐ช๏ธ Geto's Veil Channel Noise |
โก Yuji & Megumi Decoder Team |
This project implements a Hamming Error Correction Code system disguised as a Jujutsu Kaisen mission:
- Encode an image using Hamming(8,4) error correction
- Simulate channel errors (Geto's curse) with random bit flips
- Decode and correct errors to recover the original image
- Apply XOR decryption to reveal the final hidden message
Bit Position | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
Purpose | P1 | P2 | P3 | D1 | P4 | D2 | D3 | D4 |
- P1, P2, P3, P4: Parity bits for error detection/correction
- D1, D2, D3, D4: Data bits (4 bits of actual image data)
c1 = D1 โ D2 โ D4
c2 = D1 โ D3 โ D4
c3 = D2 โ D3 โ D4
c4 = D2 โ D3 โ D4
Error Position = 4รc3 + 2รc2 + 1รc1
jujutsu-kaisen-decoder/
โโโ ๐ binary_con.py # Mechamaru's Encoder
โโโ ๐ Channel.py # Geto's Veil (Error Simulation)
โโโ ๐ decoding.py # Yuji & Megumi's Decoder
โโโ ๐ README.md # This file
โโโ ๐ผ๏ธ image.png # Original input image
โโโ ๐๏ธ output.bin # Encoded data
โโโ ๐๏ธ received.bin # Data after channel errors
โโโ ๐๏ธ Array_to_be_Xored.bin # Geto's curse (XOR mask)
โโโ ๐ผ๏ธ outputimage.png # Final decoded image
pip install opencv-python numpy
image.png
- Original grayscale image (will be resized to 1000ร500)Array_to_be_Xored.bin
- XOR mask for final decryption
python binary_con.py
What this does:
- Loads
image.png
and converts to grayscale - Resizes to 1000ร500 pixels (500,000 pixels total)
- Flattens to binary stream (4,000,000 bits)
- Applies Hamming(8,4) encoding
- Saves encoded data to
output.bin
python Channel.py
What this does:
- Introduces random bit flips with 2% error probability
- Simulates real-world communication channel noise
- Saves corrupted data to
received.bin
python decoding.py
What this does:
- Reads corrupted data from
received.bin
- Applies Hamming error correction to each 8-bit codeword
- Recovers original 4-bit data segments
- XORs with
Array_to_be_Xored.bin
to break Geto's final curse - Displays and saves the recovered image as
outputimage.png
def hamming(input, output):
# Place data bits
output[7] = input[3] # D4
output[6] = input[2] # D3
output[5] = input[1] # D2
output[3] = input[0] # D1
# Calculate parity bits
output[0] = input[0] ^ input[1] ^ input[2] ^ input[3] # P1
output[1] = input[0] ^ input[1] ^ input[3] # P2
output[2] = input[0] ^ input[2] ^ input[3] # P3
output[4] = input[2] ^ input[1] ^ input[3] # P4
def hamming_decode(input, output):
# Check parity bits
c1 = input[1] ^ input[3] ^ input[5] ^ input[7]
c2 = input[2] ^ input[3] ^ input[5] ^ input[7]
c3 = input[4] ^ input[5] ^ input[6] ^ input[7]
c4 = input[3] ^ input[5] ^ input[6] ^ input[7]
# Calculate error position
num = (4*c3) + (2*c2) + (1*c1)
# Correct error if detected
if num != 0:
input[num] = input[num] ^ 1
# Extract corrected data
output[0] = input[3] # D1
output[1] = input[5] # D2
output[2] = input[6] # D3
output[3] = input[7] # D4
Metric | Value |
---|---|
Error Correction Capability | 1-bit per 8-bit codeword |
Code Rate | 4/8 = 50% |
Channel Error Rate | 2% (configurable) |
Image Dimensions | 1000 ร 500 pixels |
The system's effectiveness can be measured by:
- Visual comparison between original and decoded images
- Peak Signal-to-Noise Ratio (PSNR) calculations
- Bit Error Rate (BER) before and after correction
- Structural Similarity Index (SSIM) for image quality assessment
Common Issues
Image not displaying properly?
- Ensure OpenCV is properly installed
- Check that image dimensions are exactly 1000ร500 after processing
File not found errors?
- Make sure all required
.bin
files are in the project directory - Run scripts in the correct order: encoder โ channel โ decoder
Memory issues?
- The project processes 4M bits of data - ensure sufficient RAM
- Consider processing in smaller chunks for very large images
# In Channel.py
error_probability = 0.05 # Change from 0.02 to 5% error rate
# In binary_con.py
resized_image = cv2.resize(image, (width, height)) # Modify as needed
The framework can be extended to support:
- BCH Codes
- Reed-Solomon Codes
- Turbo Codes
- LDPC Codes
This project is released under the MIT License. Feel free to use, modify, and distribute as needed.
- Gege Akutami - Creator of Jujutsu Kaisen manga
- Richard Hamming - Inventor of Hamming codes
- OpenCV Community - Image processing library
- NumPy Developers - Numerical computing foundation
Mission Status: โ COMPLETE
Geto's curse has been broken, and Gojo's image has been successfully recovered!