CSc 7003, Programming for Data Science (Summer 2021)

Image Processing in Python

Command to install PIL package

pip install pillow
or
pip3 install pillow
Write a Python program, called Jigsaw.py, that works as follows:
  1. The program begins by displaying the following picture in a window labeled "Original Picture".

    The jpg image is 720x480 in size.

  2. Then, the program cuts the image into 6 pieces, each 240x240 in size, and scrambles the six pieces randomly and displays the scrambled image in a separate window labeled "Scrambled Image". A sample scrambled image is shown below:

  3. Then, the program continually prompts the user for two cell numbers (each cell number ranges from 0 to 5; where cells 0, 1 , and 2 correspond to the 3 images in the first row and cells 3, 4, and 5 correspond to the 3 images in the second row).
    Cell number (0-5) to exchange (6 to quit): 1
    Cell number (0-5) to exchange: 2
    
    If the first cell number entered by the user is 6, the program stops. Otherwise, the program exchanges the the two images at the two cells and displays the altered image in a window labeled "Exchanged Picture".

    You may try to cut the image into smaller squares, e.g. 6x4 = 24 squares and then play the puzzle game!