0% found this document useful (0 votes)
14 views

Python GUI for Image Processing Applications_removed

The document discusses digital image processing, outlining its key principles, types, and fundamental steps, including image acquisition, preprocessing, segmentation, representation, and description. It also covers various image enhancement techniques, such as histogram equalization and median filtering, as well as the creation of a GUI for an image editor using Python's Tkinter library. The document further details the functionalities and libraries used in the GUI application, including Pillow and NumPy.

Uploaded by

gowdasumanth228
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Python GUI for Image Processing Applications_removed

The document discusses digital image processing, outlining its key principles, types, and fundamental steps, including image acquisition, preprocessing, segmentation, representation, and description. It also covers various image enhancement techniques, such as histogram equalization and median filtering, as well as the creation of a GUI for an image editor using Python's Tkinter library. The document further details the functionalities and libraries used in the GUI application, including Pillow and NumPy.

Uploaded by

gowdasumanth228
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

CHAPTER – 3

DIGITAL IMAGE PROCESSING


3.1 DIGITAL IMAGE PROCESSING

The pillars of digital image processing are mainly built from 2 principal areas of interest:
1. High picture quality for predicting the humans correctly.
2. Processing is done on train dataset for our model to perform well.

In the latter, interest follows on performing the list of steps for extraction the desired
information from the image in a suitable processing format.
Image:
An image is nothing but a 2D light intensity function f(x, y), which signifies the brighter or
darker levels in an image at that point, for different spatial coordinates x and y. A digital image
is encoded in discrete values for both spatial coordinates and intensity level. We thereby form
an array of digital image, which comprises of image elements or pixel values.
A simple image model:
For computing processor suitability, the image is digitally encoded in both spatial coordinates
and function height. Such a digitalization done for coordinates is called image sampling.
Digitalization done for the intensity function is called gray-level quantization.
With the increase of picture quality resolution or pixel value, and gray levels, the storage also
increases which demands high processor for it.
Example: A gray-scale image of pixel value size 256x256 requires a space of 64k bytes of
memory.
3 Types of image processing
• Low level
• Medium level
• High level
A lower level processing is responsible for carrying out primary tasks like image reading,
resizing, rotating an image, converting color form (RGB to gray), drawing histograms etc. We
obtain the raw image after this processing. Medium level processing is used for extraction of
important features from the output of the previously formed image. It correctly identifies the
boundaries (edges) in an image, which is called segmentation. High level processing then adds
artificial intelligence concepts for making our system intelligent and smart to learn new things
by it.

13 | P a g e
3.2. FUNDAMENTAL STEPS IN IMAGE PROCESSING

1. Acquiring a raw digital image

2. Image pre-processing: enhancing the features of image such that the probability of success of
further steps performed increases.

3. Image segmentation: to segment the various parts present in an input image.

4. Representing image: For applying the processing techniques, raw image is converted into
suitable format.

5. Image description: extracting such feature that differentiates the classes for objects.

SEGMENTING REPRESENTATION
. AND DESCRIPTION

PREPROCESSING

INTELLIGENT BLOCK
IMAGE
ACQUISTION

FIG.3.1. FUNDAMENTAL STEPS IN DIGITAL IMAGE PROCESSING

14 | P a g e
3.3. ELEMENTS OF DIGITAL IMAGE PROCESSING SYSTEMS

FIG.3.2. ELEMENTS OF DIGITAL IMAGE PROCESSING

The important stages involved in processing of the digital image are:


1. Image acquired
2. Storing capacity
3. Processor required
4. Channel for communicating
5. Displaying the final image

3.3.1. A SIMPLE IMAGE FORMATION MODEL


Image is represented as a 2-D function f(x, y), which consists of 2 spatial components x and y:

1. The intensity of the source light I(x, y) incident on an image.


2. The intensity of reflected light R(x, y) from the objects of an image.
3. f(x, y) = I(x, y),R(x, y); where 0 < I(x,y) < 1 and 0 < R(x, y) < 1

15 | P a g e
TABLE 3.3. DIFFERENT IMAGE FORMATS

3.4. IMAGE ENHANCEMENT

Image Enhancement is the methodology of improving the quality and data content of the actual
information or data prior to processing. It is a way towards changing or adjusting of digital
images so that the outcomes which we obtain are more reasonable to show or to do further
image analysis.

16 | P a g e
For example-

 It can remove unwanted noise and disturbances.


 It makes it simpler to distinguish key highlights.
 It sharpens up the image.
 It brightens up an image.

3.4.1. METHODS OF IMAGE ENHANCEMENT

3.4.1.1. HISTOGRAM EQUALIZATION

Histogram Equalization is a method for changing image intensities to improve contrast of the
image. This strategy typically builds or increases the global contrast of numerous images,
particularly when the usable information of the image is addressed by close contrast values.

Fig 3.3- Enhancing grayscale images with the help of Histogram Equalization.

3.4.1.2. MEDIAN FILTERING

Median Filtering is a technique which is usually used to eliminate noise and disturbance from
images. This type of decrease in noise and disturbances is a typical pre processing step to
enhance the consequences of later processing.

Fig 3.4- Median Filtering

17 | P a g e
3.4.1.3. UNSHARP MASK FILTERING

The unsharp Mask Filtering Technique is a basic technique which hones or sharpens the
operator which further gets it name from that it improves, sharpens and enhances edges
through a methodology which deducts smoothed, unsharped redintion of an image from its
original picture.

Fig 3.5- Unsharp Mask Filtering

3.4.2. METHODS OF IMAGE SEGMENTATION

3.4.2.1. EDGE BASED SEGMENTATION

Edge detection is the way toward finding edges in a picture which is a vital advances towards
understanding picture highlights. It is accepted that edges comprise of significant highlights and
contains huge data. It altogether diminishes the size of the picture that will be prepared and sift
through data that might be viewed as less applicable, safeguarding and zeroing in exclusively on
the significant underlying properties of a picture for a business issue.

18 | P a g e
Edge-based segmentation calculations work to identify edges in a picture, in view of different
discontinuities in grey level, shading, surface, brilliance, immersion, contrast and so on To
additional upgrade the outcomes, advantageous preparing steps should follow to link every one
of the edges into edge chains that relate better with borders in the picture.

Fig 3.6- Edge Based Segmentation

19 | P a g e
CHAPTER – 4
BUILDING A GUI USING PYTHON
4.1. STEPS FOR CREATING GUI
There are several steps involved in creating GUI for an application such as importing a desired
module which is best fit for the application, then adding various widgets like button, list box,
etc and implementing the geometry managers for improving the GUI layout. And finally, we can
ensemble our model by adding key elements from other GUIs.

4.1.1. IMPORT THE MODULE


The first step for starting our work in an application is importing the desired module. It can be
done by importing the module in user’s namespace. It allows user to classes and constants by
their names. Therefore, we can label our own text instead of using the default tKinter label. It is
relatively easy and time consuming approach.
User can use >> from Tkinter import to import the necessary module.
Thus, now user can start building its GUI by following further steps.

4.1.2. CREATING BUTTONS


Now, once the Tkinter starts running, the user can add buttons to its GUI. Buttons are the most
simplest of all widgets in the GUI applications.
>>b = Button(win, text=”Hello”)
The window created previously acts as a parent for the button added now. But after writing the
code, the buttons aren’t available on the screen because of absence of geometry managers
(pack, grid and place). Therefore, next step would be implementing these geometrical
managers.

4.1.3. IMPLEMENTING PACK MANAGER


Now, we will use the pack manager for adding buttons to the parent window. The user can
define that where he wants his child widget to be packed in a parent widget by using functions

20 | P a g e
TOP, BOTTOM, LEFT, RIGHT. By default, the program considers the function TOP, until
mentioned by the user.
>> b.pack()
The window adjusts itself according to the button size. The pack manager places the widgets in
horizontal or vertical direction only. For placing the widget in any other way, we use GRID
manager that uses x and y coordinates for placing the widget.

4.1.4. GRID MANAGER


Grid manager allows the parent class to divide into rows and columns. The child widget can be
placed in parent grid’s cell. The modifications on the length and the width of every row and
column can be done as per the user’s choice. The grid manager gives user the complete
freedom in designing the widgets.
>> b = Button(win, text=”HELLO”)
>> b.grid(row=1, column=1)

4.1.4. IMPROVING LAYOUT


The frame contains various widgets. A user can pack many widgets in a single frame. Also, many
frames can be packed inside a single frame. Thus, with these features, advance GUI layouts can
be created.
The buttons created before are unresponsive; they do not function until the user assigns them
some particular task to perform.
>> b.configure(text=”highlight”)
>> def bx()
print(“Button one was pushed”)
>> b.configure(command=bx)
So, when the user clicks the button, the respective message will be displayed in the window.

21 | P a g e
4.1.5. ADDING SOME WIDGETS

4.1.5.1. BUTTONS

4.1.5.2. CANVAS
It is used in drawing pictures and some complex layouts like texts, graphics and widgets.

22 | P a g e
4.1.5.3. CHECKBUTTONS
The user can select any option from variety of options available as a toggle buttons.

4.1.5.4. ENTRY
This widget allows the user to input the single line test.

4.1.5.5. FRAME
It acts a main window that comprises of all the widgets. It is also used for organizing and
arranging the widgets.

23 | P a g e
4.1.5.6. LISTBOX
It provides user list of options to choose from.

4.1.5.7. MENU
It is used to create all kinds of menu options used in an application.

4.1.5.8. MESSAGE
It is a multi line text. It cannot be edited once declared by the user.

24 | P a g e
4.1.5.9. RADIOBUTTON
The user can choose one option from the several options available.

4.1.5.10. TEXT
It is used to format or edit the multi line text.

4.1.6. PYTHON LIBRARIES USED

4.1.6.1 TKINTER
Tkinter is one of the most commonly used python library for developing GUI. It doesn’t require
any license for the users to use, hence it is a free software. Tkinter is compatible with many
major platforms like Unix, Linux, Microsoft windows, Mac OS, etc. It has many built in features
to create various widgets like buttons, check buttons, menu button, allows user to write a text
on or around an image and many other options. Although Python has several options available
for GUI designing for applications like PySimple GUI, Wax, PySide, Libavg, tKinter, PyQt, Kivy,
etc; out of these tKinter is the fastest and easiest way to create GUI applications. Creating a GUI
using tKinter is an easy task. Tkinter is pre installed in Python 3, so the user don’t have to install
it separately.

4.1.6.2 PILLOW LIBRARY


Pillow library has all the basic image processing functionalities. It can perform functions like
image transformation, image rotation, image resizing and many more. This module permits to
haul a few statistical data out of the image utilizing histogram strategy, which further moving
on can be utilized for automatic contrast enhancement and statistical analysis.

4.1.6.3 IMAGE MODULE IN PILLOW LIBRARY


Image Module in Pillow Library gives a class a similar same which is utilized to address a PIL
Image. This module additionally gives various factory functions, including functions to create
new images and to load images from files.

4.1.6.4 IMAGETK MODULE IN PILLOW LIBRARY


ImageTK Module in Pillow Library contains support to make and adjust Tkinter BitmapImage
and PhotoImage objects from PIL images. Filedialog is utilized for the dialog box to appear
whenever you are opening file from anyplace in system or saving file at a specific location or
spot.

25 | P a g e
4.1.6.5 IMAGEOPS MODULE IN PILLOW LIBRARY
ImageOps Module in Pillow Library contains various instant image processing operations. This
module to some degree is trial or experimental, and mainly operators work on L amd RGB
images.

4.1.6.6 IMAGEENHANCE MODULE IN PILLOW LIBRARY


ImageEnhance Module in Pillow Library contains various classes which can be utilized for image
enhancement.

4.1.6.7 TKINTER IMPORT FILEDIALOG


Python Tkinter offers a bunch of dialogs that can be utilized while working on with the
documents. By utilizing these we do not need to plan standard dialog exchanges by ourselves.
File dialogs helps in opening of the files, saving of the files or even directories. It allows us to
open a single file, a directory, save as file and substantially much more.

4.1.6.8 NUMPY
NumPy is one of the most important or in other words one of the main libraries in Python as it
provides support for arrays. An image is essentially a standard NumPy array containing pixels of
data points. Therefore, pixel values of an image can be modified by using
basic NumPy operations, such as slicing, masking, and fancy indexing.

4.1.6.9 IMAGEFILTER MODULE IN PILLOW LIBRARY


ImageFilter Module in Pillow Library contains definitions of pre-defined set of filters, which can
be utilized with Image.filter() method.
The current adaptation of the library provides the accompanying arrangement of predefined
image enhancement filters-
 Detail
 Contour
 Blur
 Edge_Enhance
 Edge_Enhance_More
 Smooth_More
 Smooth
 Emboss
 Sharpen
 Find_Edges
This strategy permits you to apply practically any shading change in constant time with the use
of pre-determined decimated tables.

26 | P a g e
CHAPTER – 5
APPLICATION PROTOTYPE

5.1 GUI INTERFACE OF IMAGE EDITIOR

This is the main GUI interface for Image Editor.

Fig 5.1

27 | P a g e
5.2 DROPDOWN MENU

This Image Editor can edit photos by selecting the images present in the secondary storage of
the device.

Fig 5.2

28 | P a g e
5.3 SELECTED AN IMAGE

After clicking on “Select Image” from the dropdown menu the image will be selected.

Fig 5.3

29 | P a g e
5.4 CROPPED IMAGE AND OTHER EDITING FEATURES

We can crop the selected image by clicking on “Editing” button and a dropdown menu will
appear from which we can further select “Crop” button and it will automatically crop the image
So that the image fits perfectly in the canvas of the Image Editor.

Fig 5.4

30 | P a g e
5.5 APPLIED FILTERS IN THE IMAGE

Now moving on, if we want to change the enhancements of the image then we can select the
Automatic Mode and it will directly change filters and brightness of picture and enhance the
image. If we want to enhance the image by using more filters then custom filters options is also
available and we can select other filter and effects.

Fig 5.5

31 | P a g e
5.6 NEW ADDITIONS IN THE GUI

I have added to new buttons in the Image Editor GUI which are-:

 Image Segmentation
 Image Enhancement

Fig 5.6

32 | P a g e
5.7 ENHANCEMENT FILTERS

On clicking the Enhancement button three image enhancement techniques will appear which
are-

 Histogram Equalization
 Median Filtering
 Unsharp Mask Filtering

Fig 5.7

33 | P a g e
5.8 HISTOGRAM EQUALIZATION

On clicking Histogram Equalization a slider will appear which will be numbered 1 to 10, and
using which we can apply this technique.

Fig 5.8

34 | P a g e
5.9 MEDIAN FILTERING

On clicking Median Filtering a slider will appear which will be numbered 1 to 10, and using
which we can apply this technique.

Fig 5.9

35 | P a g e
5.10 UNSHARP MASK FILTERING

On clicking Unsharp Mask Filtering we can apply this technique.

Fig 5.10

36 | P a g e
5.11 SEGMENTATION FILTER

On clicking Segmentation edge based segmentation technique button will appear.

Fig 5.11

37 | P a g e
5.12 EDGE BASED SEGMENTATION

On clicking Edge based we can apply this technique.

Fig 5.12

38 | P a g e

You might also like