Skip to content

The repository, code, explanations and FAQs for Assignment 1 of IPR class.

License

Notifications You must be signed in to change notification settings

NotAProPilot/IPR_Assignment-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPR Assignment 1

This GUI-based approach turns a normal, simple exercise about image resizing and binary image thresholding into a delightful interactive experience akin to playing with digital building blocks. Gone are the days of tediously typing commands into a terminal or wrestling with complicated software interfaces. With just a few clicks and drags, users can effortlessly manipulate images.

Program structure:

image

There are 2 requirements for this prorgam: Resize photo and display binary image. For each task, there are 2 files (as shown on the figure above): A GUI file that create the GUI windows, accept user inputs and parse them to the back end files (ImgResize and MakePhotoBinary). The structure can be shown in the diagram below:

+-----------------------+           +-----------------------+            +-----------------------+
|        GUI File       |           |      Backend File      |            |      Application      |
+-----------------------+           +-----------------------+            +-----------------------+
| - title: customtkinter|           |                       |            |      - app: CTk       |
| - height_var: StringVar|           |                       |            +-----------------------+
| - width_var: StringVar|           |                       |
|                       |           |                       |
| + handle_resize()     |           | + image_resize()      |
| + handle_path_input() |           |                       |
+-----------------------+           +-----------------------+
                |                                |
                |                                |
                |                                |
                |                                |
                |                                |
                +--------------------------------+
                                   |
                                   |
                                   |
                                   |
                                   v
+-----------------------+
|      Libraries        |
+-----------------------+
| - OpenCV              |
| - Matplotlib          |
+-----------------------+

Instruction

Select the program

After downloading, your IDE will show 4 files: GUI_ImgResize, GUI_MakePhotoBinary, ImgResize, MakePhotoBinary. The program wll only run from the appopriate GUI file.

Resize image

First, run the GUI_ImgResize file. A window will pop up, like this: image

Enter the height and the width (in pixel) of your photo that the resized image would be in. For example, if you want to resize the image to 1280x720, enter like this: image

Then select the image you want to resize: image

- IMPORTANT: File name must not contain Unicode character (other than English character).

Press "Resize Image", and the resized image will be displayed: image

Display binary image:

First, run the GUI_MakePhotoBinary file. A window will pop up, like this: image

Enter the binary threshold (must be between 0 and 255). For the best result, It's recommended set the binary value to 128: image

If you enter an out-of-bound binary threshold, a error message will pop up: image

Then select the image you want to display binary image: image

Press "Display Binary Image", and a Mathplotlib plot will show both the original (in RGB color, if selected) and the binary image: image

Frequently Asked Questions (FAQs)

Do i need to install any outside libraries?

Yes. You will need the following:

  • customtkinter (install by pip install customtkinter==0.3)
  • OpenCV (install by pip install opencv-python)
  • Mathplotlib (install by pip install matplotlib) (tkinter is buitt-in in Python, but you still need to import it by:)
import tkinter

Acknowledgement:

This Assignment made extensive use of the CustomTkinter library.

For debugging, I want to thanks the following StackOverflow thread for the following fixes:

For general approach to GUI via CustomTkinter

About

The repository, code, explanations and FAQs for Assignment 1 of IPR class.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages