Image_shuffler package in Python
This library is used to split an image into ‘n’ no. of parts and then shuffle it. Before going to dive into the topic first, we need to set up the python environment and install the required packages. To install this package run this command into the terminal.
pip install image_shuffler
Now we have to download the image which we want to shuffle.
Image for demonstration
Now let us see the code which shuffles the image using image_shuffler package
Example 1: We will be using an image name pic.jpg and then shuffle it using image_shuffler library.
Python3
# importing image_shuffler package from image_shuffler import Shuffler # Reading the image from local directory # to python environment img = Shuffler( 'pic.jpg' ) # specifying the matrix to shuffle img.shuffle(matrix = ( 3 , 3 )) # displaying & saving the shuffled # image img.show() img.save() |
Output:
Example 2:
Python3
# importing image_shuffler package from image_shuffler import Shuffler # Reading the image from local directory to # python environment img = Shuffler( 'pic.jpg' ) # specifying the matrix to shuffle img.shuffle(matrix = ( 4 , 4 )) # displaying and saving the shuffled image img.show() img.save() |
Output :
Shuffling Images in Python
In this article, we will learn how to shuffle an image using the image_shuffler package in Python.