-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.m
47 lines (38 loc) · 1.13 KB
/
test.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
clear;clc;close all;
imds = imageDatastore('D:\data\GAMMA_fil','FileExtensions',{'.bmp'});
img_num = length(imds.Files);
for i = 1:1
for j = i+7
[img1,map1] = imread(imds.Files{i},'bmp');
[img2,map2] = imread(imds.Files{j},'bmp');
img1 = double(round(img1));
img2 = double(round(img2));
Ic = img_diff(img1,img2);
I_v = reshape(Ic,1,[]);
Ic_hist = imhist16(Ic)/1e6;
figure;
stem(Ic_hist,'.')
grid on
%% zhishu distribution
hold on
x = 0:0.1:255;
lambda = 1/mean(mean(Ic));
f_e = f_exp(x,lambda);
plot(x,f_e,'LineWidth',2);
legend('hist','exp');
title(['img',num2str(i),' and img',num2str(j),''])
fprintf('the %d and %d diff\n',i,j);
saveas(gcf,['D:\image\',num2str(i),'and',num2str(j),''],'png');
hold off;
end
end
%% contrast
pix = 0:(length(Ic_hist)-1);
diff_hist = Ic_hist - f_exp(pix,lambda);
figure;
stem(diff_hist(2:end))
title(['img',num2str(i),' and img',num2str(j),''])
grid on;
function y = f_exp(x,lambda)
y = lambda*exp(-lambda*x);
end