0% found this document useful (0 votes)
78 views7 pages

Accurate of Digital Image Rotation Using Matlab

Accurate of Digital Image Rotation Using Matlab

Uploaded by

Ni Pramesti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views7 pages

Accurate of Digital Image Rotation Using Matlab

Accurate of Digital Image Rotation Using Matlab

Uploaded by

Ni Pramesti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Accurate of Digital Image Rotation Using Matlab

Abstract
Image rotation is one of main pre-processing steps for image processing or image pattern
recognition. This paper proposes a fast source code of MATLAB for rotating images while
preserving their quality. The new approach rotates images based on vertical or horizontal
lines in the original image and their rotated equation in the target image. It is implemented
with a rotation matrix multiplication. Therefore, there has been a need for a high speed
image rotation source code without two major time-consuming operations.
Keywords : High speed rotation operation, image rotation, transform matrix, image
processing.

I. Introduction
Recently, image pattern recognition technology has been applied in a number of ways in
various areas. The preprocessing step is essential in the technology. The rotation is one of
the major pre-processing methods. It is implemented with a rotation matrix multiplication,
easily. Highly accurate image rotation is essential for certain image processing tasks such
as feature extraction and matching. Furthermore, in many applications, especially real-
time systems, a high speed of rotation is important. However, it requires lots of floating
point arithmetic operations and trigonometric function calculations, so it takes long
execution time. Hence, it is necessary and advantageous to define a method that provides
both high accuracy and fast execution. Image rotation can be described as the movement
of an image around a fixed point.

II. Related Works


Conventional rotation transform could be described with a matrix multiplication form
which has two sine and two cosine functions in (1). Let a pixel P in a given image location
(x, y). New rotated pixel position of P, P’, could be calculated as (1). Then the pixel P’ is
obtained by rotating the pixel P in counter-clockwise angle θ (Fig. 1).

(1)
Fig.1

Determining the rotated point directly using a single function such as (1) is a one-pass
technique, whereas calculating the rotated point using multiple functions such as (2), (3),
and (4) is a multi-pass technique. Compared with multi-pass methods, one-pass methods
are simple and usually more accurate. However, although one-pass methods are accurate,
they are still inefficient because multiple high-level calculations and computations are
required. As presented in (1), four floating-point multiplications and two floating-point
additions are required to calculate each rotated pixel. For an image of many pixels, the
one-pass method can actually take longer than multi-pass methods.
1
(2)

(3)

(4)

III. Purposed Source Code


To solve this problem a new recovery rotation source code is proposed here to prepare the
attacked image before performing extraction process. The source code is implemented to
be pluggable to the extraction component in any image. This source code is developed to
automatically detect, estimate and recover rotations for acute angles rotated scenes without
need to a reference image. This is due to the difficulty to estimate the acute rotations in
images accurately.
Here is the source code to make the image rotation program :
function varargout = Rotasi(varargin)

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Rotasi_OpeningFcn, ...
'gui_OutputFcn', @Rotasi_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before Rotasi is made visible.


function Rotasi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Rotasi (see VARARGIN)

% Choose default command line output for Rotasi


handles.output = hObject;

2
movegui(hObject,'center');
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Rotasi wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command


line.
function varargout = Rotasi_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see
VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of
edit1 as a double

% --- Executes during object creation, after setting all


properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles empty - handles not created until after all
CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on slider movement.


function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)

3
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine
range of slider
nilai_slider = get(handles.slider1,'Value');
handles.nilai_slider = round(nilai_slider);
set(handles.edit1,'String',handles.nilai_slider);
hasil =
imrotate(handles.data1,handles.arah*handles.nilai_slider,...
'bilinear','crop');
handles.hasil = hasil;
guidata(hObject,handles);
axes(handles.axes2);
imshow(hasil,[]);

% --- Executes during object creation, after setting all


properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles empty - handles not created until after all
CreateFcns called

% Hint: slider controls usually have a light gray background.


if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end

% --- Executes on button press in radiobutton1.


function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


set(handles.radiobutton2,'value',0);
arah = 1;
handles.arah = arah;
guidata(hObject,handles);

% --- Executes on button press in radiobutton2.


function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2


set(handles.radiobutton1,'value',0);
arah = -1;
handles.arah = arah;
guidata(hObject,handles);

% --- Executes on button press in pushbutton1.

4
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see GUIDATA)
[nama_file,nama_path] =
uigetfile({'*.jpg';'*.bmp';'*.png';'*.tif'},...
'Buka Gambar');
if ~isequal(nama_file,0);
handles.data1 = imread(fullfile(nama_path,nama_file));
guidata(hObject,handles);
axes(handles.axes1);
imshow(handles.data1,[]);
axes(handles.axes2);
imshow(handles.data1,[]);
else
return
end

IV. Experiments And Analysis


To demonstrate the performance of the source code presented, the analysis and
experiments of time complexity were carried out by various image sizes: original image,
positive rotated image, and image in negative rotation.
The experimental results using MATLAB R2014a and Windows 8.1 Pro. From the source
code above, will show the application as below :

Fig. 2

After the image is uploaded, user must select the desired rotation direction. And sliding
the slider up to the slope of the desired image. The degree of rotation of the image can be
seen in the box degree of rotation description.

5
Fig. a Fig. b

Fig. c

The image-rotation methods are evaluated based on two measures: accuracy and speed. A
high accuracy of image rotation is fundamental for follow-up processing such as feature
extraction and feature matching.
The first image is the original image which has not received rotation treatment (Fig.a),
samples with Bird, where in the images are directly rotated by 32 degrees in a negative
direction (Fig.b), samples with Bird, where in the images are directly rotated by 32
degrees in a positive direction (Fig.c)

V. Conclusion
In this paper, the rotation image correction source code is created, which is based on the
accuracy of the rotation degree of the image the user wants. First, the source code is
verified in MATLAB, and finally implemented in c ++, and applied to an image.
Compared with the conventional rotational correction, through the rotation angle obtained
by calculating the correlation coefficient, the source code in this paper greatly reduces the
time complexity, and increases the degree of rotational accuracy can be seen by
description box.

References
[1] Nasr addin Ahmed and Aznul Qalid, “Automatic Rotation Recovery Algorithm for
Accurate Digital Image and Video Watermarks Extraction”, International Journal of
Advanced Computer Science and Applications, Vol. 7, No. 11, 2016.

[2] S. Suchitra, S.K. Lam, C.T. Clarke and T. Srikanthan, “Accelerating rotation of high-
resolution images”, IEE Proc.-Vis. Image Signal Process., Vol. 153, No. 6, December
2006.

6
[3] Kunyan Li, and Tian Dan, “Fast Rotation and Correction of image algorithm Based on
Local Feature”, International Workshop on Microwave and Millimeter Wave Circuits
and System Technology 978-1-4673-5504-9/13/$31.00 ©2013 IEEE.

[4] Zhongda Yu, Junyu Dong, Zhiqiang Wei and Jianxiang Shen, “A Fast Image Rotation
Algorithm for Optical Character Recognition of Chinese Documents”, 0-7803-9584-
0/06/$20.00(2006 IEEE.

[5] Fuming LI and Zhijia ZHANG, “Angle Correction Algorithm for Image Rotation
Based on Key Point Detection”, Journal of Computational Information Systems 9: 4
(2013) 1307–1314.

[6] Weimin Wei, Shuozhong Wang, Xinpeng Zhang, and Zhenjun Tang, “Estimation of
Image Rotation Angle Using Interpolation-Related Spectral Signatures With
Application to Blind Detection of Image Forgery”, IEEE TRANSACTIONS ON
INFORMATION FORENSICS AND SECURITY, VOL. 5, NO. 3, SEPTEMBER
2010.

[7] Valery Starovoitov and Dmitry Samal, “Comparison of rotation algorithms for digital
images”, SPIE Conference on Vision Geometry VIII • Denver, Colorado • July 1999.

[8] G. Costantini, D. Casali and R. Perfetti, “Cellular neural network template for rotation
of grey-scale images”, ELECTRONICS LETTERS 11th December 2003 Vol. 39 No.
25.

[9] Ruohan Qian, Weihai Li, Nenghai Yu, and Bin Liu, “High Precision Image Rotation
Angle Estimation with Periodicity of Pixel Variance”, 2013 Seventh International
Conference on Image and Graphics.

[10] Amir Hossein, Md Jan Nordin, and Seyed Mostafa, “Double Line Image Rotation”,
IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 24, NO. 11,
NOVEMBER 2015.

You might also like