-
Notifications
You must be signed in to change notification settings - Fork 26
/
main_map2uint8.py
37 lines (32 loc) · 1.15 KB
/
main_map2uint8.py
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
# This code converts the noiseprint_blind output in a PNG image
# python main_mat2uint8.py output.mat output.png
#
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
# Copyright (c) 2019 Image Processing Research Group of University Federico II of Naples ('GRIP-UNINA').
# All rights reserved.
# This work should only be used for nonprofit purposes.
#
# By downloading and/or using any of these files, you implicitly agree to all the
# terms of the license, as specified in the document LICENSE.txt
# (included in this package) and online at
# http://www.grip.unina.it/download/LICENSE_OPEN.txt
#
from sys import argv
mapfilename = argv[1]
outfilename = argv[2]
if mapfilename[-4:] == '.mat':
import scipy.io as sio
dat = sio.loadmat(mapfilename)
else:
import numpy as np
dat = np.load(mapfilename)
mapp = dat['map']
valid = dat['valid']
range0 = dat['range0'].flatten()
range1 = dat['range1'].flatten()
imgsize = dat['imgsize'].flatten()
from noiseprint.noiseprint_blind import genMappUint8
mapUint8 = genMappUint8(mapp, valid, range0, range1, imgsize)
from PIL import Image
Image.fromarray(mapUint8).save(outfilename)