-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcompute_psnr.lua
executable file
·59 lines (45 loc) · 1.85 KB
/
compute_psnr.lua
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
require 'torch'
require 'paths'
require 'image'
require 'my_image_error_measures'
local lfs = require 'lfs'
path_true = arg[1]
path_synthesized = arg[2]
local list_of_filenames = {}
local filenamesonly_no_dir = {}
for file in lfs.dir(path_synthesized) do -- get the list of the files
if file~="." and file~=".." then
table.insert(filenamesonly_no_dir, file)
end
end
local number_of_files = #filenamesonly_no_dir
--ssim_synthesized = 0.0
--sharpness_synthesized = 0.0
psnr_synthesized = 0.0
for inputs = 1, number_of_files do -- number_of_files --define no of images to compute upon
filename = filenamesonly_no_dir[inputs]
local img_true = path_true..'/'..filename
local img_synthesized = path_synthesized..'/'..filename
local im_true = image.load(img_true)
local im_synthesized = image.load(img_synthesized)
--ssim_synthesized = ssim_synthesized + SSIM(im_true, im_synthesized)
psnr_synthesized = psnr_synthesized + PSNR(im_true, im_synthesized)
--sharpness_synthesized = sharpness_synthesized + computel1difference(im_true, im_synthesized)
if inputs%500 ==0 then
print("..........................................\n")
print("Images into consideration:"..inputs.."\n")
print ("For synthesized: ")
--print ("SSIM: "..ssim_synthesized/inputs)
print ("PSNR: "..psnr_synthesized/inputs)
--print ("Sharpness: "..sharpness_synthesized/inputs)
print("")
end
end
print("\n..........................................\n")
print("Final numbers\n")
print("Images into consideration:"..number_of_files.."\n")
-- print ("For synthesized: ")
--print ("SSIM: "..ssim_synthesized/number_of_files)
print ("PSNR: "..psnr_synthesized/number_of_files)
--print ("Sharpness: "..sharpness_synthesized/number_of_files)
-------------------------------------------------------------------------------------------------------------------------------