Raport Tehnic Tanase Marian

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

Raport tehnic – Image Rotation

Nume Echipa: Jinx&Judy


Membrii echipei
 Manager: Marian Beniamin-Mihai
 Dezvoltator: Tanase Valentin
Nume îndrumător: Camelia Florea
Data predării proiectului (zi/lună/an): 16.01.2020

ABSTRACT
Image rotation is a common image processing routine with applications in matching,
alignment, and other image-based algorithms. The input to an image rotation routine is an image,
the rotation angle θ, and a point about which rotation is done. It is most commonly used to improve
the visual appearance of an image. An image can be the subject of a perspective irregularity wherein
the position of the camera with respect to the scene alters the apparent dimensions of the scene
geometry.
The algorithm was implementend in C#, with Microsot Visual Studio. The developing of the
app was done using EMGU.CV. The basic algorithm that we used is simple and efficient. We
assume that the rotation angle is a part of our input. Furthermore, for simplicity of argument we
assume that the document is rotated in a counter-clockwise way. Rotation in the opposite direction
can be dealt within a symmetric manner. Based on some equations, we calculate the sine and cosine
value of the specific number, then also we compute the corresponting values for the rotated image.
Afterwards there it should take place the rotation transformation of the image and in the end we will
display the original and the transformed resulting image.
As a major advantage, we can say that the algorithm works safely in any conditions because
we started to compute our coordinates using the center of our input images. Therefore, our results
would not be damaged in any way by the working process.

INTRODUCTION
Rotation can be useful as a preprocessor in applications where directional operators are
involved. Applying this transformation to a uniformly distorted image can correct for a range of
perspective distortions by transforming the measurements from the ideal coordinates to those
actually used. For example, this is useful in satellite imaging where geometrically correct ground
maps are desired.
We implemented image rotation algorithm using a set of final equations which were obtained
from a specific rotation matrix. The result will be a rotation of a certain image by a given angle
established by the user.

MATHEMATICAL APPROACH
The rotation algorithm performs a geometric transform which maps the position (𝑥1 , 𝑦1 ) of
a picture element in an input image onto a position (𝑥2 , 𝑦2 ) in an output image by rotating it through
a user-specified angle 𝜃 about an origin 0. In most implementations, output locations (𝑥2 , 𝑦2 ) which
are outside the boundary of the image are ignored.
The transformation has the form:

𝑥𝑗 1 −𝑡𝑎𝑛(𝜃/2) 1 0 1 −𝑡𝑎𝑛(𝜃/2) 𝑢𝑝
[𝑦 ]=[ ][ ][ ] [𝑣 ]
𝑘 0 1 sin(𝜃) 1 0 1 𝑞

Equation 1 transform matrix

From which we will obtain in final form:

𝑥2 = cos(𝜃) ∗ (𝑥1 − 𝑥0 ) − sin(𝜃) ∗ (𝑦1 − 𝑦0 ) + 𝑥0


𝑦2 = sin(𝜃) ∗ (𝑥1 − 𝑥0 ) − cos(𝜃) ∗ (𝑦1 − 𝑦0 ) + 𝑦0
Equation 2 Final equations

Where:
 (𝑥0 , 𝑦0 ) are the coordinates of the center of rotation in the input image.
 x1 and y1 are the original coordinates
 x2 and y2 are the new coordinates
 𝜃 is the angle of rotation with clockwise rotations having positive angles.
 We are working in image coordinates, so the y axis goes downward, but similar rotation
formula can be defined for when the y axis goes upward.

The steps to implement our project are the following:


1. We get the desired degree of rotation as an input from the user.
2. The image should be a default one.
3. After we get the rotation degree, we read the image coordinates and apply the algorithm.
4. At the end we should display the original image, and the changes in each step, like this :

Figure 1 Original image and the changing steps of the image


Block scheme of the implementation :

Establish the Calculate the sin/cos of Calculate the corresponding

angle 𝜽 the number value for the rotated image

Display the original and the Rotation transformation

transformed image of the image

Figure 2 Block scheme of the implementation

IMPLEMENTATION OF THE SOLUTION


The algorithm was implemented in C#, with Microsot Visual Studio. The developing of the app
was done using EMGU.CV.
What is Visual Studio?
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is
used to develop computer programs, as well as websites, web apps, web services and mobile apps.
Visual Studio uses Microsoft software development platforms such as Windows API, Windows
Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce
both native code and managed code.
Visual Studio includes a code editor supporting IntelliSense (the code completion component)
as well as code refactoring. The integrated debugger works both as a source-level debugger and a
machine-level debugger. Other built-in tools include a code profiler, forms designer for building GUI
applications, web designer, class designer, and database schema designer. It accepts plug-ins that
enhance the functionality at almost every level—including adding support for source control systems
(like Subversion and Git) and adding new toolsets like editors and visual designers for domain-
specific languages or toolsets for other aspects of the software development lifecycle (like the Team
Foundation Server client: Team Explorer).
Visual Studio supports 36 different programming languages and allows the code editor and
debugger to support (to varying degrees) nearly any programming language, provided a language-
specific service exists. Built-in languages include C,[6] C++, C++/CLI, Visual Basic .NET, C#, F#,[7]
JavaScript, TypeScript, XML, XSLT, HTML, and CSS. Support for other languages such as
Python,[8] Ruby, Node.js, and M among others is available via plug-ins. Java (and J#) were
supported in the past.
The most basic edition of Visual Studio, the Community edition, is available free of charge.
What is EMGU?
Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library. Allowing
OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython
etc. The wrapper can be compiled by Visual Studio, Xamarin Studio and Unity, it can run on
Windows, Linux, Mac OS X, iOS, Android and Windows Phone.
Advantages of Emgu CV:
 Cross-platform
Emgu CV is totally written in C#. The advantage it brings is that it is compatible with Mono so
that our Emgu CV program can be launched on any platform with Mono, such as Linux PC, Android,
iOS, and Mac OS X. Headers can be simply included in managed C++ implementation, but great
effort has been taken to build this pure C# implementation to achieve cross-platform. However, it's
still quite considerable if Emgu CV is able to run on your Ubuntu or Fedora PC, let alone the fact
that you'll always be comfortable knowing that your code is compatible and cross-platform.
 Cross-language support with examples
Emgu CV is able to run in multiple language environments, including VB.NET, IronPython, C#,
and C++. Several instances have been provided on the official website for all those languages,
which can be accessed from the Examples section on the Tutorial page . You can also visit the
Emgu CV Discussion Forum to solve your language-related questions.

IMPLEMENTATION OF THE ALGHORITM


= = = = = = = = = = = = = = = = = = = = = = = = = = = ROTIREA IMAGINII = = = = = = = = = = = = = = = = = = =
Bibliografie
1.Basic OpenCL Examples. Benedict R. Gaster, Dana Schaa, in Heterogeneous Computing
with OpenCL (Second Edition), 2013
https://www.sciencedirect.com/topics/computer-science/image-rotation
2. [HIPR] The Hypermedia Image Processing Reference (HIPR) from the Department of
Artificial Intelligence in the University of Edinburgh solution for rotating an image[Online 09.01.2019]
https://homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm

You might also like