Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Basic photo editor

5/30/2021

Students
1.Mohamed Mosad Eldebany 16p8221
2.Mohamed Elsaieed zidan 15p8116
3.Mirna ashraf alamir 15p7051
Contents
Problem definition and importance...........................................................................................................4
1. Definition of rotation......................................................................................................................4
2. Definition of flipping.......................................................................................................................4
3. Definition of Cropping.....................................................................................................................4
4. Definition of Perspective Transformation......................................................................................4
Importance..................................................................................................................................................4
Methods and Algorithms............................................................................................................................5
1. Flipping............................................................................................................................................5
2. Perspective Transformation............................................................................................................5
3. Crop.................................................................................................................................................5
4. Rotate..............................................................................................................................................6
Experimental Results..................................................................................................................................7
1. Reading the image..........................................................................................................................7
2. Flipping option................................................................................................................................7
3. Cropping option..............................................................................................................................9
4. Rotation option.............................................................................................................................10
5. Perspective Transformation option..............................................................................................11
Appendix with codes................................................................................................................................13
 Main edit functions.......................................................................................................................13
 GUI code........................................................................................................................................14
 GUI Function..................................................................................................................................16
 Update Function............................................................................................................................16
 Reset Button..................................................................................................................................17
 Apply Button.................................................................................................................................17
 Main Function...............................................................................................................................18
Table Of Content
Figure 1 Perspective Transformation Algorithm..........................................................................................5
Figure 2 Main GUI........................................................................................................................................7
Figure 3 Flipping about y axis......................................................................................................................7
Figure 4 Flipping about x axis......................................................................................................................8
Figure 5 Flipping about x and y Axes...........................................................................................................8
Figure 6 Cropping Edit 1..............................................................................................................................9
Figure 7 Cropping Edit 2..............................................................................................................................9
Figure 8 Rotation By 45 Degree.................................................................................................................10
Figure 9 Rotation By 90 Degree.................................................................................................................10
Figure 10 Rotation By 190 Degree.............................................................................................................11
Figure 11 Perspective Transformation Of mars rover................................................................................11
Figure 12 Reading Sudoku Image..............................................................................................................12
Figure 13 Perspective Transformation for Sudoku Image..........................................................................12
Figure 14 Saving Edited images In Same Directory....................................................................................13
Figure 15 Main Edit Function.....................................................................................................................13
Figure 16 GUI Code 1.................................................................................................................................14
Figure 17 GUI Code 2.................................................................................................................................14
Figure 18 GUI Code 3.................................................................................................................................15
Figure 19 GUI Code 4.................................................................................................................................15
Figure 20 GUI Function..............................................................................................................................16
Figure 21 Update Function........................................................................................................................16
Figure 22 Reset Function...........................................................................................................................17
Figure 23 Applying Function......................................................................................................................17
Figure 24 Main Function............................................................................................................................18
Problem definition and importance
1. Definition of rotation.
When referring to an image or image editor, rotate is a feature that allows you to turn
an image in a clockwise or counterclockwise direction. For example, many editors allow you to
rotate images 90, 180, or 270. Below is an example of the Computer Hope logo and what it
would look like rotated at 90, 180, and 270-degrees clockwise.

2. Definition of flipping
A flipped image or reversed image, the more formal term, is a static or moving
image that is generated by a mirror-reversal of an original across a horizontal axis (a
flopped image is mirrored across the vertical axis)

3. Definition of Cropping
Cropping is the removal of unwanted outer areas from a photographic or
illustrated image. The process usually consists of the removal of some of the peripheral
areas of an image to remove extraneous trash from the picture, to improve its framing, to
change the aspect ratio, or to accentuate or isolate the subject matter from its background.

4. Definition of Perspective Transformation


In general terms, perspective means when human eyes see an object, it looks
bigger when it is close to the eye and smaller when it is far from the eyes. Transformation
means the transfer of an object from one state to another. Perspective transformation
works in the same principle in which human vision and camera work that is the
conversion of the 3D world into a 2D image.

Importance
Digital Image Processing, Digital Image Analysis, and Computer Vision can be
viewed as an amalgam of terms that very often are used to describe similar processes and
applications, generating confusion regarding their meaning. Most of the confusion arises
because these are interconnected fields that emerged with the development of
technologies for digital image acquisition. For the sake of clarity, we can divide and
define these three areas as follows.
 Engineering is another field where high-quality images are pivotal. In
engineering, there are various sections dealing with images including CAD designs, 2D
drafting images, floor plans, 2D or 3D product images, 3D renderings, etc. It is very key
that these images are evident and detailed so that end-users find them no-brainer. While
drawing these images in various designing software, it is highly likely that quality will be
degraded. Therefore, these images must be post processed to bring the desired quality.
Hence, to do so, the engineering companies require professional high-end image editing
services to optimize their valuable visuals and these optimized visuals will ultimately
drive client growth.
Methods and Algorithms
1. Flipping
A flip (mirror effect) is done by reversing the pixels horizontally or vertically. For
instance, for an horizontal flip, the pixel situated at coordinate (x, y) will be situated at
coordinate (width - x - 1, y) in the new image.

2. Perspective Transformation
The goal of perspective (projective) transform is to estimate homography (a
matrix, H) from point correspondences between two images. Since the matrix has
a Depth Of Field (DOF) of eight, you need at least four pairs of points to compute the
homography matrix from two images. The following diagram shows the basic concepts
required to compute the homography matrix: 

Figure 1 Perspective Transformation Algorithm

3. Crop
In order to crop an image, we need to copy in a new image the pixels we want to
keep. Let origin be the coordinate of upper-left corner and end the coordinate of the
bottom-right corner. The pixel at coordinate (x, y) in the new image is equal to the pixel
located at coordinate (x + origin.x, y + origin.y) in the old image.
4. Rotate

The algorithm used for a rotation is similar to a flip: to compute the new image,
we iterate over all the pixels and print the corresponding pixel from the source image.

The point situated at the coordinates (x, y) in the new image is equal to the point (xp, yp)
in the input image:

If (xp, yp) is out of the input image, it is ignored (black pixel).

This can be used to do a rotation, however, the center of the rotation will be at coordinate
(0, 0). In order to change the coordinates of the center of the rotation, we need to shift the
coordinates before the rotation and after the rotation:
Experimental Results

1. Reading the image

Figure 2 Main GUI

The image must me in same folder of the .py file and its name is original.

2. Flipping option

Figure 3 Flipping about y axis.


Figure 4 Flipping about x axis.

Figure 5 Flipping about x and y Axes.

The flipping has three option 0, 1, and -1 relative to y, x, and both y and x.
3. Cropping option

Figure 6 Cropping Edit 1

Figure 7 Cropping Edit 2

To flip the image, you must enter the start point, width, and length of the cropped image.
4. Rotation option

Figure 8 Rotation By 45 Degree.

Figure 9 Rotation By 90 Degree.


Figure 10 Rotation By 190 Degree.

To rotate, you must enter the angle of rotation.

5. Perspective Transformation option

Figure 11 Perspective Transformation Of mars rover

you must enter the four points of the object you want to transform.
Figure 12 Reading Sudoku Image

Figure 13 Perspective Transformation for Sudoku Image.

Obvious image of transformation


The program will save every edit you did in the save directory with the name of select
edit.

Figure 14 Saving Edited images In Same Directory.

Appendix with codes


 Main edit functions

Figure 15 Main Edit Function.


 GUI code

Figure 16 GUI Code 1.

Figure 17 GUI Code 2.


Figure 18 GUI Code 3.

Figure 19 GUI Code 4.


 GUI Function

Figure 20 GUI Function.

To display the GUI Window

 Update Function

Figure 21 Update Function.

To make the GUI take effect after applying the function.


 Reset Button

Figure 22 Reset Function.

To return the original image in the GUI

 Apply Button

Figure 23 Applying Function.

To know which option is selected and apply its specific function.


 Main Function

Figure 24 Main Function.

You might also like