ROTATE_CVIP
rotate_cvip() - Rotate an image by a given angle (in degrees).
Contents
SYNTAX
[outImage] = rotate_cvip(inImage, theta)
Input Parameters include:
- inImage - Input image of MxN or MxNxB size.
- theta - Angle in degree (-360 < theta < +360). (90 | default)
Output Parameter includes:
- outImage - Rotated image
DESCRIPTION
The function rotates the image by the degree specified by the user. The transformation equations used are X=xcos(rads)+ysin(rads); Y=-xsin(rads)+ycos(rads); Where, X=shifted x co-ordinate, Y = shifted y co-ordinate, and rads = number of radians to be rotated. For the 4 corners of the image, the shifted co-ordinates are found out and from that the new image size can be calculated. For each co-ordinate in the new image the corresponding co-ordinate in the old image is calculated, if it falls with in the range of the old image size,the corresponding pixel value is copied, otherwise the pixel value is set to zero.
REFERENCE
1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.
EXAMPLE
% Read image I = imread('cam.bmp'); % Calling function using default parameters O1 = rotate_cvip(I); % Theta theta = -60; % Calling function using user defined parameters O2 = rotate_cvip(I,-60); % Display input image figure; imshow(I); title('Input image'); % Display output image figure; imshow(O1/255);title('Output image using default parameters'); figure; imshow(O2/255);title('Output image using user defined parameters');
CREDITS
Author: Norsang Lama, Febrauary 2017
Copyright © 2017-2018 Scott
E Umbaugh
For updates visit CVIP Toolbox Website