summaryrefslogtreecommitdiff
path: root/3176/CH4/EX4.13/Ex4_13.sce
blob: dbc2fc15336520f8430becfcd82aab6b0bbb8ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//Ex4_13
//The 2-D Fourier Spectrum of a Simple Function
// Version : Scilab 5.4.1
// Operating System : Window-xp, Window-7
//Toolbox: Image Processing Design 8.3.1-1
//Toolbox: SIVP 0.5.3.1-2
//Reference book name : Digital Image Processing
//book author: Rafael C. Gonzalez and Richard E. Woods

clc;
close;
clear;
xdel(winsid())//to close all currently open figure(s).
a=imread("Ex4_13_1.tif");
a=imresize(a,0.5);
//gray=rgb2gray(a);
gray=im2double(a);

figure,ShowImage(gray,'Gray Image');
title('Original Image','color','blue','fontsize',4);
[M,N]=size(gray);

h1=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
figure,ShowImage(mat2gray(abs(h1)),'Frequency spectrum');
title('Frequency spectrum','color','blue','fontsize',4);

in=fftshift(h1);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
figure,ShowImage(mat2gray(abs(in)),'Frequency spectrum');
title('Centred Frequency spectrum','color','blue','fontsize',4);

i=log(1+abs(in));
inm=mat2gray(i)
figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing  a title to an image.

/////////////////////////// Effect of Translation   //////////////////////////////
a=imread("Ex4_13_2.png");
gray=rgb2gray(a);
gray=im2double(gray);
figure,ShowImage(gray,'Gray Image');
title('Original Image','color','blue','fontsize',4);
[M,N]=size(gray);
h2=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
i=log(1+abs(h2));
in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
inm=mat2gray(in)
figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing  a title to an image.

/////////////////////////// Effect of Rotation   //////////////////////////////
a=imread("Ex4_13_3.png");
gray=rgb2gray(a);
gray=im2double(gray);
figure,ShowImage(gray,'Gray Image');
title('Original Image','color','blue','fontsize',4);
[M,N]=size(gray);
h3=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
i=log(1+abs(h3));
in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
inm=mat2gray(in)
figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing  a title to an image.


/////////////////////////// Phase Spectrum   //////////////////////////////
phase=atand(imag(h1),real(h1));
phase_1=mat2gray(phase);
figure,ShowImage(phase_1,'phase Spectrum');
title('phase Spectrum','color','blue','fontsize',4);

phase=atand(imag(h2),real(h2));
phase_1=mat2gray(phase);
figure,ShowImage(phase_1,'phase Spectrum');
title('phase Spectrum of Translated Object','color','blue','fontsize',4);

phase=atand(imag(h3),real(h3));
phase_1=mat2gray(phase);
figure,ShowImage(phase_1,'phase Spectrum');
title('phase Spectrum of Rotated Object','color','blue','fontsize',4);