Shuffling Images in Python
Last Updated :
24 Nov, 2022
In this article, we will learn how to shuffle an image using the image_shuffler package in Python.
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
from image_shuffler import Shuffler
img = Shuffler( 'pic.jpg' )
img.shuffle(matrix = ( 3 , 3 ))
img.show()
img.save()
|
Output:
Example 2:
Python3
from image_shuffler import Shuffler
img = Shuffler( 'pic.jpg' )
img.shuffle(matrix = ( 4 , 4 ))
img.show()
img.save()
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...