Skip to content

Encode/decode images using Base64 or shuffle/recover the pixels of images.

License

Notifications You must be signed in to change notification settings

ZhanZiyuan/PixelPuzzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PixelPuzzle

Encode/decode images using Base64 or shuffle/recover the pixels of images.

Motivations

This repository is a renewed implementation of Python code I saw a long time ago on CoolApk:

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

# Get the three-dimensional pixel channel matrix of the image
img = np.array(Image.open("C:/Users/user/Downloads/test.png"))
# First dimension
row_len = img.shape[0]

# Shuffle the dimension indices
row_index = np.random.permutation(row_len)
# Generate the chaotic image
img_chaos = img[row_index, :, :]

# Use sorting to unshuffle the image
img_sort = img[np.sort(row_index), :, :]

# Plot the chaotic and unshuffled images
plt.figure('Chaotic and Unshuffled Images')
plt.subplot(121)
plt.imshow(img_chaos)
plt.subplot(122)
plt.imshow(img_sort)
plt.show()

And it can also be seen as an implementation of similar functions of the Android application 图片混淆 in Python.

Examples

  • The original image:

    The original image

  • The shuffled image:

    The shuffled image

    The .npz file key.npz stores the original positions of pixels.

  • The recovered image:

    The recovered image

Packaging

The binaries are created with Nuitka:

# Show Nuitka version
python -m nuitka --version

# Package it on Linux
python -m nuitka --onefile --remove-output pixel_puzzle.py

# Package it on Windows
python -m nuitka --onefile --remove-output --windows-icon-from-ico="python.ico" pixel_puzzle.py

TODO

Deploy web applications using:

Similar Projects

Here are some links to other similar projects that I am aware of:

Copyrights

Warning

Contents of this repository may cause some copyright issues. Please raise issues to let me know if that happens.

PixelPuzzle is a free, open-source software package (distributed under the GPLv3 license). Some of the references are as follows:

The Python Software Foundation owns the copyright of Python icon. The sample image used is downloaded from satchely doki doki literature club! natsuki.