To play
with images using some matlab commands.
close all;
clear all;clc;
a
= imread('flowers.jpg'); % imread function
display('size of original image, stored in a')
size(a)
subplot(3,3,1)
imshow(a) % imshow function
title('imread
stores image values in a ')
b
= imresize(a,[64,64]); % imresize function
display('size of resized image to a new scale')
size(b)
subplot(3,3,4)
imshow(b) % imshow function
title('imresize
resizes image to a new scale values')
c
= rgb2gray(a);
display('size of grayscale image ')
size(c)
subplot(3,3,2)
imshow(c)
title('rgb2gray
converts rgb image to grayscale')
d
= imresize(c,[64 64]);
display('size of resized grayscale image')
size(d)
subplot(3,3,3)
imshow(d)
title('resized grayscale image ')
subplot(3,3,5)
imhist(c)
title('histogram of grayscale image of a ')
subplot(3,3,6)
imhist(d)
title('histogram of resized grayscale image ')
e
= imadd(c,50);
subplot(3,3,7)
imhist(d)
title('histogram of image after adding 50')
x=[20
30];
y=[50
60];
subplot(3,3,8)
improfile(c,x,y)
title('improfile of grayscale image')
subplot(3,3,9)
improfile(e,x,y)
title('improfile of image after adding 50')
Output –
size of original image, stored in a1600 2560 3
sizeof resized image to a new scale 64
64 3
close
all;
clear
all;clc;
b
= imread('porche.jpg');
c
= im2bw(a,0.4)
d
= im2bw(b,0.5)
e
= imcomplement(a)
f
= imcomplement(b)
g
= imresize(c,[512 512]);
h
= imresize(d,[512 512]);
i
= g | h
j
= g & h
k
= xor(g,h)
subplot(3,3,1)
imshow(a) % imshow function
title('imread
stores image values in a ')
subplot(3,3,4)
imshow(b) % imshow function
title('imread
stores image values in b ')
subplot(3,3,2)
imshow(c) % imshow function
title('im2bw
converts rgb image into binary ')
subplot(3,3,5)
imshow(d) % imshow function
title('im2bw
converts rgb image into binary ')
subplot(3,3,3)
imshow(e) % imshow function
title('imcomplement
complements rgb image ')
subplot(3,3,6)
imshow(f) % imshow function
title('imcomplement
complements rgb image ')
subplot(3,3,7)
imshow(i) % imshow function
title('oring of two images ')
subplot(3,3,8)
imshow(j) % imshow function
title('anding of two images ')
subplot(3,3,9)
imshow(k) %
imshow function
title('ex-oring of two images ')
clc;
close all;
clear all;
T
= maketform('projective',[.5 0 0; .5 2 0; 0 0 1]);
tformfwd([50
100],T)
I
= imread('ferrari.jpg');
I2
= imtransform(I,T);
subplot(2,2,1)
imshow(I)
title('original image')
subplot(2,2,3)
imshow(I2)
title('translated image')
J
= imread('porche.jpg');
A
= imrotate(J,-45);
subplot(2,2,2)
imshow(A)
title('rotate image clockwise')
B=imrotate(J,45);
subplot(2,2,4)
imshow(B)
title('rotate image counter clockwise ')
No comments:
Post a Comment