clean up, start on display key, fix smoothing
parent
22750b5a8c
commit
d8bb0c7565
|
@ -164,3 +164,31 @@ cython_debug/
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
Binary file not shown.
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 27 KiB |
|
@ -0,0 +1,28 @@
|
||||||
|
<table class="legend">
|
||||||
|
<tr>
|
||||||
|
<th>Color</th>
|
||||||
|
<th>Temperature</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="legend-cell"><div style="width:20px;height:20px;background-color:red;"></div></td>
|
||||||
|
<td class="legend-cell">700°C</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="legend-cell"><div style="width:20px;height:20px;background-color:red;"></div></td>
|
||||||
|
<td class="legend-cell">800°C</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="legend-cell"><div style="width:20px;height:20px;background-color:red;"></div></td>
|
||||||
|
<td class="legend-cell">900°C</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="legend-cell"><div style="width:20px;height:20px;background-color:red;"></div></td>
|
||||||
|
<td class="legend-cell">1000°C</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.legend-cell {
|
||||||
|
padding: 4px 14px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -2,25 +2,35 @@ import math
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numba import jit
|
from numba import jit
|
||||||
|
import json
|
||||||
|
|
||||||
# camera settings
|
# camera settings
|
||||||
file = '01-0001.png'
|
file = '01-0001.png'
|
||||||
I_Darkcurrent = 150.5
|
I_Darkcurrent = 150.5
|
||||||
exposure_time = 0.5
|
exposure_time = 0.500
|
||||||
f_stop = 2.4
|
f_stop = 2.4
|
||||||
ISO = 64 # basically brightness
|
ISO = 64 # basically brightness
|
||||||
|
|
||||||
# runtime config
|
# pyrometry config
|
||||||
MAX_GR_RATIO = 2000
|
MAX_GR_RATIO = 1200
|
||||||
MIN_GR_RATIO = None
|
MIN_GR_RATIO = 0
|
||||||
|
# original range from paper
|
||||||
|
# MAX_GR_RATIO = 1200
|
||||||
|
# MIN_GR_RATIO = 600
|
||||||
|
|
||||||
|
# Cropping config
|
||||||
x1 = 420
|
x1 = 420
|
||||||
x2 = 1200
|
x2 = 1200
|
||||||
y1 = 400
|
y1 = 400
|
||||||
y2 = -1
|
y2 = -1
|
||||||
|
|
||||||
|
# post-processing
|
||||||
|
smoothing_radius = 2
|
||||||
|
|
||||||
@jit(nopython=True)
|
@jit(nopython=True)
|
||||||
def rg_ratio_normalize(imgarr):
|
def rg_ratio_normalize(imgarr):
|
||||||
|
tmin = MAX_GR_RATIO
|
||||||
|
tmax = 0
|
||||||
imgnew = imgarr
|
imgnew = imgarr
|
||||||
for i in range(len(imgarr)):
|
for i in range(len(imgarr)):
|
||||||
for j in range(len(imgarr[i])):
|
for j in range(len(imgarr[i])):
|
||||||
|
@ -29,21 +39,36 @@ def rg_ratio_normalize(imgarr):
|
||||||
g_norm = normalization_func(px[1])
|
g_norm = normalization_func(px[1])
|
||||||
|
|
||||||
# apply camera calibration func
|
# apply camera calibration func
|
||||||
ratio = pyrometry_calibration_formula(g_norm, r_norm)
|
temp_C = pyrometry_calibration_formula(g_norm, r_norm)
|
||||||
|
|
||||||
# remove edge cases
|
# remove pixels outside calibration range
|
||||||
if MAX_GR_RATIO != None and ratio > MAX_GR_RATIO or MIN_GR_RATIO != None and ratio < MIN_GR_RATIO:
|
if MAX_GR_RATIO != None and temp_C > MAX_GR_RATIO or MIN_GR_RATIO != None and temp_C < MIN_GR_RATIO:
|
||||||
ratio = 0
|
temp_C = 0
|
||||||
|
|
||||||
|
# update min & max
|
||||||
|
if temp_C < tmin and temp_C >= 0:
|
||||||
|
tmin = temp_C
|
||||||
|
if temp_C > tmax:
|
||||||
|
tmax = temp_C
|
||||||
|
|
||||||
|
imgnew[i][j] = [temp_C, temp_C, temp_C]
|
||||||
|
return imgnew, tmin, tmax
|
||||||
|
|
||||||
imgnew[i][j] = [ratio, ratio, ratio]
|
|
||||||
return imgnew
|
|
||||||
|
|
||||||
@jit(nopython=True)
|
@jit(nopython=True)
|
||||||
def normalization_func(i):
|
def normalization_func(i):
|
||||||
|
"""
|
||||||
|
does something to the pixels that i don't understand lol
|
||||||
|
"""
|
||||||
return (i - I_Darkcurrent) * (f_stop ** 2) / (ISO * exposure_time)
|
return (i - I_Darkcurrent) * (f_stop ** 2) / (ISO * exposure_time)
|
||||||
|
|
||||||
|
|
||||||
@jit(nopython=True)
|
@jit(nopython=True)
|
||||||
def pyrometry_calibration_formula(i_ng, i_nr):
|
def pyrometry_calibration_formula(i_ng, i_nr):
|
||||||
|
"""
|
||||||
|
Given the green-red ratio, calculates an approximate temperature
|
||||||
|
in Celsius.
|
||||||
|
"""
|
||||||
return 362.73 * math.log10(
|
return 362.73 * math.log10(
|
||||||
(i_ng/i_nr) ** 3
|
(i_ng/i_nr) ** 3
|
||||||
) + 2186.7 * math.log10(
|
) + 2186.7 * math.log10(
|
||||||
|
@ -52,6 +77,7 @@ def pyrometry_calibration_formula(i_ng, i_nr):
|
||||||
(i_ng / i_nr) ** 3
|
(i_ng / i_nr) ** 3
|
||||||
) + 3753.5
|
) + 3753.5
|
||||||
|
|
||||||
|
|
||||||
# read image & crop
|
# read image & crop
|
||||||
file_name = file.split(".")[0]
|
file_name = file.split(".")[0]
|
||||||
file_ext = file.split(".")[1]
|
file_ext = file.split(".")[1]
|
||||||
|
@ -61,29 +87,17 @@ cv.imwrite(f'{file_name}-cropped.{file_ext}', img)
|
||||||
|
|
||||||
# img = cv.imread('ember_test.png')
|
# img = cv.imread('ember_test.png')
|
||||||
|
|
||||||
img = rg_ratio_normalize(img)
|
img, tmin, tmax = rg_ratio_normalize(img)
|
||||||
|
|
||||||
# apply smoothing conv kernel
|
print(f"min: {tmin}°C")
|
||||||
kernel = np.array([
|
print(f"max: {tmax}°C")
|
||||||
[1/2, 1/2],
|
|
||||||
[1/2, 1/2],
|
|
||||||
])
|
|
||||||
|
|
||||||
# kernel = np.array([
|
# build & apply smoothing conv kernel
|
||||||
# [1/3, 1/3, 1/3],
|
k = []
|
||||||
# [1/3, 1/3, 1/3],
|
for i in range(smoothing_radius):
|
||||||
# [1/3, 1/3, 1/3],
|
k.append([1/(smoothing_radius**2) for i in range(smoothing_radius)])
|
||||||
# ])
|
# for j in range(smoothing_radius):
|
||||||
|
kernel = np.array(k)
|
||||||
# kernel = np.array([
|
|
||||||
# [1/4, 1/4, 1/4, 1/4],
|
|
||||||
# [1/4, 1/4, 1/4, 1/4],
|
|
||||||
# [1/4, 1/4, 1/4, 1/4],
|
|
||||||
# [1/4, 1/4, 1/4, 1/4],
|
|
||||||
# ])
|
|
||||||
|
|
||||||
# Scaling adjustment factor
|
|
||||||
kernel *= 3/5
|
|
||||||
|
|
||||||
img = cv.filter2D(src=img, ddepth=-1, kernel=kernel)
|
img = cv.filter2D(src=img, ddepth=-1, kernel=kernel)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import ratio_pyrometry
|
||||||
|
|
||||||
|
@jit(nopython=True)
|
||||||
|
def normalization_func_customizable(i, I_Darkcurrent, ISO, f_stop, exposure_time):
|
||||||
|
return (i - I_Darkcurrent) * (f_stop ** 2) / (ISO * exposure_time)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue