-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjpegAnalyse.m
32 lines (28 loc) · 919 Bytes
/
jpegAnalyse.m
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
function [ tamperMap ] = jpegAnalyse(imagePath)
disp(['Processing image ' imagePath]);
im = imread(imagePath);
OutputMap = GetDCTArtifact(im);
normA = OutputMap - min(OutputMap(:));
normA = normA ./ max(normA(:));
[counts,binLocations] = imhist(normA);
%histogram(normA);
[max_num, max_idx]=max(counts(:));
threshold_idx = 0;
for i = length(counts):-1:1
if(counts(i)>max_num*0.033)
threshold_idx = i;
break;
end
end
thresh = binLocations(threshold_idx);
A = OutputMap;
A(normA>thresh) = 1;
A(normA<=thresh) = 0;
A1 = imclose(A,strel('disk',5));
A2 = imopen(A1,strel('disk',3));
A3 = imclose(A2,strel('disk',20));
A4 = imresize(A3,[1500 2000]);
out = imfill(A4);
thresh2 = graythresh(out); %global image threshold using Otsu's method
tamperMap = imbinarize(out,thresh2); %binarize
end