-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathirg.py
More file actions
44 lines (31 loc) · 987 Bytes
/
irg.py
File metadata and controls
44 lines (31 loc) · 987 Bytes
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
import subprocess
import sys
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
print("installing dependancies")
install("opencv-python")
install("numpy")
import numpy as np
import cv2
import math
import sys
import os
def loadimg(name):
return cv2.imread(name, cv2.IMREAD_UNCHANGED)
def processFile(path):
print("processing " + path)
#convert images to signed double (int16)
inputFile=loadimg(path)
ir = inputFile[:,:,0]
green = inputFile[:,:,1]
red = inputFile[:,:,2]
irMat = np.float32(ir)
gMat = np.float32(green)
gMat = cv2.subtract(gMat,irMat*.8)
rMat = np.float32(red)
rMat = cv2.subtract(rMat,irMat+.65)
output = cv2.normalize(cv2.merge((gMat, rMat, irMat*.6)), None, 255, 0, cv2.NORM_MINMAX, cv2.CV_8UC1)
path = os.path.split(path)
cv2.imwrite(os.path.join(path[0], "out-"+path[1]), output)
for i in range (1, len(sys.argv)):
processFile(sys.argv[i])