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