clc
close all

% Read a colour Image and Resize it to 256 x 256
% Convert the image to grey image and display it

f = imread('pot.jpg');
g1=imresize(f,[256,256],'nearest');
g = rgb2gray(g1);
subplot(2, 2, 1);
imshow(g); title('Original Grey Image');

% Create a translation matrix for x direction - 50 units and y direction
% in 100 units. Use the command maketform to create the affine matrix
% for translation and imtransform to translate the image

t = [ 1 0 0; 0 1 0; 50 100 1];
tform = maketform('affine',t);
translateimg = imtransform(g,tform);
subplot(2, 2, 2);
imshow(translateimg),title('Translated Image');

% Create a rotation matrix for pi/6
% Use the command imtransform to rotate the image using the created
% rotation matrix

subplot(2, 2, 3);
t = pi/6;
r = [cos(t) sin(t) 0; -sin(t) cos(t) 0; 0 0 1];
tform = maketform('affine',r);
rotimg = imtransform(g,tform);
imshow(rotimg),title('Rotated image');

% Use the imrotate command to rotate the image in clockwise direction
% 45 degrees - Use negative values for angle if the rotation required is
% clockwise direction as the default rotation is in counter clockwise
% direction. Additional parameter 'crop' is given to ensure that the
% output image is same as the input image

subplot(2, 2, 4);
h = imrotate(g,-45,'crop');
imshow(h);title('Rotated by 45 degree in clockwise direction');

MATLAB CODE - Image Translating and Rotating Reviewed by Suresh Bojja on 10/20/2015 07:00:00 PM Rating: 5

## Subjects & Labs

AC (6) ADS (2) ATMEL (6) AWP (5) C- Language (3) CAO (5) CDAC (1) CMC (6) CN (10) Control Sys (2) CVSM (2) DC (5) DIP (17) DLD (10) DS (4) DSD&DICA (9) DSP (6) EDC (45) Embedded (7) EMWTL (6) ENERGY AUDIT (1) Engg.Chemistry (11) Faculty Labs (1) Fuzzy (3) II MID (1) LICA (1) Linux OS (1) Materials (1) MATLAB (27) MCU IDE 8051 (1) MEMS (4) MPMC (57) MTECH (6) MWE (2) OC (1) PDC (9) Projects (8) RADAR (1) Research (9) RVSP (3) SC (1) Softwares (1) SS (1) STLD (18) TCSS (1) TSSN (1) TV Engg (1) VHDL (4) VLSI (8) WCN (1) WSN (2)

## Contact Form :

Name

Email *

Message *

Theme images by enjoynz. Powered by Blogger.