add scaling factor & equation settings
parent
d0cb7e5f72
commit
046b79ba9e
|
@ -2,8 +2,6 @@
|
|||
|
||||
.vscode/
|
||||
*.swp
|
||||
static/*
|
||||
!static/.gitkeep
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
|
|
@ -6,7 +6,7 @@ import cv2 as cv
|
|||
|
||||
app = Flask(
|
||||
__name__,
|
||||
static_folder='./static',
|
||||
static_folder='static',
|
||||
static_url_path='/s/'
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,8 @@ def ratio_pyro():
|
|||
MAX_TEMP=float(request.form['max_temp']),
|
||||
MIN_TEMP=float(request.form['min_temp']),
|
||||
smoothing_radius=int(request.form['smoothing_radius']),
|
||||
key_entries=int(request.form['legend_entries'])
|
||||
key_entries=int(request.form['legend_entries']),
|
||||
eqn_scaling_factor=float(request.form['equation_scaling_factor'])
|
||||
)
|
||||
|
||||
img_orig_b64 = base64.b64encode(cv.imencode('.png', img_orig)[1]).decode(encoding='utf-8')
|
||||
|
|
|
@ -12,7 +12,8 @@ def rg_ratio_normalize(
|
|||
exposure_time,
|
||||
ISO,
|
||||
MIN_TEMP,
|
||||
MAX_TEMP
|
||||
MAX_TEMP,
|
||||
eqn_scaling_factor
|
||||
):
|
||||
# copy image into new array & chop off alpha values (if applicable)
|
||||
imgnew = imgarr.copy()[:,:,:3]
|
||||
|
@ -26,18 +27,14 @@ def rg_ratio_normalize(
|
|||
r_norm = (px[2] - I_Darkcurrent) * (f_stop ** 2) / (ISO * exposure_time)
|
||||
|
||||
# apply camera calibration func
|
||||
temp_C = pyrometry_calibration_formula(g_norm, r_norm, default=MIN_TEMP)
|
||||
temp_C = pyrometry_calibration_formula(g_norm, r_norm, default=MIN_TEMP) * eqn_scaling_factor
|
||||
|
||||
# remove pixels outside calibration range
|
||||
if (MIN_TEMP != None and temp_C < MIN_TEMP) or (MAX_TEMP != None and temp_C > MAX_TEMP):
|
||||
temp_C = MIN_TEMP
|
||||
|
||||
# min intensity = 0
|
||||
# pix_i = temp_C - MIN_TEMP
|
||||
|
||||
temp_new = temp_C - MIN_TEMP
|
||||
pix_i = temp_new / (MAX_TEMP - MIN_TEMP) * 255
|
||||
|
||||
# scale light intensity to calculated temperature
|
||||
pix_i = scale_temp(temp_C, MIN_TEMP, MAX_TEMP)
|
||||
imgnew[i][j] = [pix_i, pix_i, pix_i]
|
||||
|
||||
return imgnew
|
||||
|
@ -59,6 +56,15 @@ def pyrometry_calibration_formula(i_ng, i_nr, default=24.0):
|
|||
except:
|
||||
return default
|
||||
|
||||
|
||||
@jit(nopython=True)
|
||||
def scale_temp(t, min, max):
|
||||
"""
|
||||
Scale pixel temperature (t) to light intensity given min & max temp.
|
||||
"""
|
||||
return (t - min) / (max - min) * 255
|
||||
|
||||
|
||||
def ratio_pyrometry_pipeline(
|
||||
file_bytes,
|
||||
# camera settings
|
||||
|
@ -70,12 +76,12 @@ def ratio_pyrometry_pipeline(
|
|||
MAX_TEMP: float,
|
||||
MIN_TEMP: float,
|
||||
smoothing_radius: int,
|
||||
key_entries: int
|
||||
key_entries: int,
|
||||
eqn_scaling_factor: float,
|
||||
):
|
||||
|
||||
# read image & crop
|
||||
img_orig = cv.imdecode(file_bytes, cv.IMREAD_UNCHANGED)
|
||||
# img = img[y1:y2, x1:x2]
|
||||
|
||||
img = rg_ratio_normalize(
|
||||
img_orig,
|
||||
|
@ -84,7 +90,8 @@ def ratio_pyrometry_pipeline(
|
|||
exposure_time,
|
||||
ISO,
|
||||
MIN_TEMP,
|
||||
MAX_TEMP
|
||||
MAX_TEMP,
|
||||
eqn_scaling_factor
|
||||
)
|
||||
|
||||
# build & apply smoothing conv kernel
|
||||
|
@ -107,7 +114,7 @@ def ratio_pyrometry_pipeline(
|
|||
key_img_arr = [[]]
|
||||
for i in range(key_entries):
|
||||
res_temp = MIN_TEMP + (i * step)
|
||||
res_color = (res_temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) * 255
|
||||
res_color = scale_temp(res_temp, MIN_TEMP, MAX_TEMP)
|
||||
temps.append(math.floor(res_temp))
|
||||
key_img_arr[0].append([res_color, res_color, res_color])
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
|
@ -29,13 +29,21 @@
|
|||
<h4>Temperature Settings</h4>
|
||||
|
||||
<label for="min_temp">Min Temp (°C)</label>
|
||||
<input type="number" name="min_temp" value="60"/>
|
||||
<input type="number" name="min_temp" value="600"/>
|
||||
<br>
|
||||
|
||||
<label for="max_temp">Max Temp (°C)</label>
|
||||
<input type="number" name="max_temp" value="1200"/>
|
||||
<br>
|
||||
|
||||
<h4>Pyrometry Equation Settings</h4>
|
||||
|
||||
<img src="/s/pyrometry_eqn.png" id="pyro-eqn" alt="pyrometry calibration formula">
|
||||
<br>
|
||||
<label for="equation_scaling_factor">Equation scaling factor (1 default, 0.55 recommended)</label>
|
||||
<input type="number" name="equation_scaling_factor" value="0.55" step="0.001"/>
|
||||
<br>
|
||||
|
||||
<h4>Output Settings</h4>
|
||||
|
||||
<label for="smoothing_radius">Smoothing Radius (px)</label>
|
||||
|
@ -66,6 +74,9 @@ imgUpload.onchange = event => {
|
|||
#img-preview {
|
||||
width: 18rem;
|
||||
}
|
||||
#pyro-eqn {
|
||||
width: 800px;
|
||||
}
|
||||
</style>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue