-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMatlab_Code
More file actions
133 lines (78 loc) · 3.61 KB
/
Matlab_Code
File metadata and controls
133 lines (78 loc) · 3.61 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
% Image tampering detection using SIFT algorithm and Discrete Wavelet transform
% Using VL feat Library for SIFT algorithm
Original_Image = imread('Original.jpg');
Tampered_Image = imread('Tampered.jpg');
Original_Image = rgb2gray(Original_Image);
Tampered_Image = rgb2gray(Tampered_Image);
————— For time being don’t touch it ——————————————
% Extracting the red component of the image and performing DWT on it.
% Original_Image = im2double(Original_Image);
% redcomp = Original_Image(:,:,3);
% [A H V D]=dwt2(redcomp,’haar');
% new_I = wcodemat(A);
% image(new_I);
——————————————————————————————————————————
SIFT using vl_libraray
% The vl_sift command requires a single precision gray scale image.
new_Original_Image = single(rgb2gray(Original_Image));
image(new_Original_Image);
new_Tampered_Image = single(rgb2gray(Tampered_Image));
image(new_Tampered_Image);
% f gives the frames and d gives the descriptors of the sift algorithm
[OriginalFrames,OriginalDescriptors] = vl_sift(new_Original_Image);
[TamperedFrames,TamperedDescriptors] = vl_sift(new_Tampered_Image);
% Where 1.5 = ratio between euclidean distance of NN2/NN1
[matches score] = vl_ubcmatch(OriginalDescriptors,TamperedDescriptors,1.5);
subplot(1,2,1);
imshow(uint8(Original_Image));
hold on;
plot(OriginalFrames(1,matches(1,:)),OriginalFrames(2,matches(1,:)),'b*');
subplot(1,2,2);
imshow(uint8(Tampered_Image));
hold on;
plot(TamperedFrames(1,matches(2,:)),TamperedFrames(2,matches(2,:)),'r*');
—————— SURF ———————————
Original_Surf_pts = detectSURFFeatures(Original_Image);
Original_Surf_pts =
147x1 SURFPoints array with properties:
Scale: [147x1 single]
SignOfLaplacian: [147x1 int8]
Orientation: [147x1 single]
Location: [147x2 single]
Metric: [147x1 single]
Count: 147
Tampered_Surf_pts = detectSURFFeatures(Tampered_Image);
158x1 SURFPoints array with properties:
Scale: [158x1 single]
SignOfLaplacian: [158x1 int8]
Orientation: [158x1 single]
Location: [158x2 single]
Metric: [158x1 single]
Count: 158
[OriginalFeatures, OriginalPoints] = extractFeatures(Original_Image, Original_Surf_pts);
[TamperedFeatures, TamperedPoints] = extractFeatures(Tampered_Image, Tampered_Surf_pts);
indexPairs = matchFeatures(OriginalFeatures, TamperedFeatures);
matchedOriginal = OriginalPoints(indexPairs(:,1));
matchedTampered = TamperedPoints(indexPairs(:,2));
figure;
showMatchedFeatures(Original_Image,Tampered_Image,matchedOriginal,matchedTampered);
—————— FAST ——————————
Original_Surf_pts = detectFASTFeatures(Original_Image);
Original_Surf_pts =
239x1 cornerPoints array with properties:
Location: [239x2 single]
Metric: [239x1 single]
Count: 239
Tampered_Surf_pts = detectFASTFeatures(Tampered_Image);
Tampered_Surf_pts =
240x1 cornerPoints array with properties:
Location: [240x2 single]
Metric: [240x1 single]
Count: 240
[OriginalFeatures, OriginalPoints] = extractFeatures(Original_Image, Original_Surf_pts);
[TamperedFeatures, TamperedPoints] = extractFeatures(Tampered_Image, Tampered_Surf_pts);
indexPairs = matchFeatures(OriginalFeatures, TamperedFeatures);
matchedOriginal = OriginalPoints(indexPairs(:,1));
matchedTampered = TamperedPoints(indexPairs(:,2));
figure;
showMatchedFeatures(Original_Image,Tampered_Image,matchedOriginal,matchedTampered);