initial commit

master
michael 2022-10-06 00:13:40 -07:00
commit ad49ff39f4
9 changed files with 406 additions and 0 deletions

166
.gitignore vendored Normal file
View File

@ -0,0 +1,166 @@
# CUSTOM
.vscode/
*.swp
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# 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.
#.idea/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
01-0001.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

13
Pipfile Normal file
View File

@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
opencv-python = "*"
numba = "*"
[dev-packages]
[requires]
python_version = "3.10"

144
Pipfile.lock generated Normal file
View File

@ -0,0 +1,144 @@
{
"_meta": {
"hash": {
"sha256": "4d38c8456723919069d64e7e19fd21317602969788feb71d5a4b4bbd183adcf2"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.10"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"llvmlite": {
"hashes": [
"sha256:03aee0ccd81735696474dc4f8b6be60774892a2929d6c05d093d17392c237f32",
"sha256:1578f5000fdce513712e99543c50e93758a954297575610f48cb1fd71b27c08a",
"sha256:16f56eb1eec3cda3a5c526bc3f63594fc24e0c8d219375afeb336f289764c6c7",
"sha256:1ec3d70b3e507515936e475d9811305f52d049281eaa6c8273448a61c9b5b7e2",
"sha256:22d36591cd5d02038912321d9ab8e4668e53ae2211da5523f454e992b5e13c36",
"sha256:3803f11ad5f6f6c3d2b545a303d68d9fabb1d50e06a8d6418e6fcd2d0df00959",
"sha256:39dc2160aed36e989610fc403487f11b8764b6650017ff367e45384dff88ffbf",
"sha256:3fc14e757bc07a919221f0cbaacb512704ce5774d7fcada793f1996d6bc75f2a",
"sha256:4c6ebace910410daf0bebda09c1859504fc2f33d122e9a971c4c349c89cca630",
"sha256:50aea09a2b933dab7c9df92361b1844ad3145bfb8dd2deb9cd8b8917d59306fb",
"sha256:60f8dd1e76f47b3dbdee4b38d9189f3e020d22a173c00f930b52131001d801f9",
"sha256:62c0ea22e0b9dffb020601bb65cb11dd967a095a488be73f07d8867f4e327ca5",
"sha256:6546bed4e02a1c3d53a22a0bced254b3b6894693318b16c16c8e43e29d6befb6",
"sha256:6717c7a6e93c9d2c3d07c07113ec80ae24af45cde536b34363d4bcd9188091d9",
"sha256:7ebf1eb9badc2a397d4f6a6c8717447c81ac011db00064a00408bc83c923c0e4",
"sha256:9ffc84ade195abd4abcf0bd3b827b9140ae9ef90999429b9ea84d5df69c9058c",
"sha256:a3f331a323d0f0ada6b10d60182ef06c20a2f01be21699999d204c5750ffd0b4",
"sha256:b1a0bbdb274fb683f993198775b957d29a6f07b45d184c571ef2a721ce4388cf",
"sha256:b43abd7c82e805261c425d50335be9a6c4f84264e34d6d6e475207300005d572",
"sha256:c0f158e4708dda6367d21cf15afc58de4ebce979c7a1aa2f6b977aae737e2a54",
"sha256:d0bfd18c324549c0fec2c5dc610fd024689de6f27c6cc67e4e24a07541d6e49b",
"sha256:ddab526c5a2c4ccb8c9ec4821fcea7606933dc53f510e2a6eebb45a418d3488a",
"sha256:e172c73fccf7d6db4bd6f7de963dedded900d1a5c6778733241d878ba613980e",
"sha256:e2c00ff204afa721b0bb9835b5bf1ba7fba210eefcec5552a9e05a63219ba0dc",
"sha256:e31f4b799d530255aaf0566e3da2df5bfc35d3cd9d6d5a3dcc251663656c27b1",
"sha256:e4f212c018db951da3e1dc25c2651abc688221934739721f2dad5ff1dd5f90e7",
"sha256:fa9b26939ae553bf30a9f5c4c754db0fb2d2677327f2511e674aa2f5df941789",
"sha256:fb62fc7016b592435d3e3a8f680e3ea8897c3c9e62e6e6cc58011e7a4801439e"
],
"markers": "python_version >= '3.7'",
"version": "==0.39.1"
},
"numba": {
"hashes": [
"sha256:0c358fd4ef7c5efc09ee96432284d66df285bd68654e85c39cf6c570dc35429a",
"sha256:2713f161c51e0638dd4f92036999a523df5dcc498d39adb1559cf7cacb6f0fe9",
"sha256:2a1d81994bedc0e02f900ea4b81bdfd4929ee844f6ef9242e196c50f30f95449",
"sha256:2e4ac02b1bacea083e7cab5c02ded3bb5db7bb35d9c3a0a63da4f8c86691365a",
"sha256:339e519f4091fab3a446b474e041c86eedd216334f8dd7febee4b43df112179c",
"sha256:3492f0a5d09e257fc521f5377a6c6b907eec1920d14739f0b2458b9d29946a5a",
"sha256:36903c24088aed9a768d7e8269f4ee4d3abc5662e2aeacacf524a7c5d1707b04",
"sha256:45cefeefa78762753c2be9f64e7579a7523afff479642c3c661fb78bd740a352",
"sha256:590112ac60ff482f1d096e7574f9a781dff2f7bc91bfe388fe7d87e52630c0ec",
"sha256:6184d0c125bdf2f19ad78e71e9ea873ad6c88c55f7609f987bd4354d15c54bb3",
"sha256:61d472e42ecad262857409a00f9f24d4609b190ba1fab5fc118e7a1ee43c9d39",
"sha256:63199334b9fedf3511369738fa8ef07411abc1cd9e8cd0e474cf671133b85180",
"sha256:6465f23beff2f6134f53da873d4202671cdbb02716a29f2b5f5c77102ece37c0",
"sha256:6b885219eba813a4c70e68fce18339a3e575fb2b75e92d2babbcf04a40f74dee",
"sha256:8a8e35d9b86d33c2f77e50fd8a610b984f57005e1cd1a2c8267d4cfd743d8f49",
"sha256:9eb56e7a23c4daa195cefba894671a45464533b0af9908483ba3de74a75fe682",
"sha256:ae89056d1681c70b79bc9835c40672d4ba22cf4e75eacc0b8ff7f176c7233781",
"sha256:bb3609bb76fd5b1d3adc9a7df40f27c3eb8c7e5d2c8a536c1bdc7b09c2fdc215",
"sha256:c011436c8e0ec7e37fbb81953537ceb659e662f7c7f9850f2638a100e857bee4",
"sha256:c4467aed831297473ec94f9f3d9795de551c447bf6ea17d7ac24b6a47fb687ea",
"sha256:d216a8957057afa43374eb9a11c69a874424d33e20f4270f80cef878c7efa500",
"sha256:d87bdb704ef219c00844844a8ac9c6f1c518f2cee9c26d1971427b6bc3d2004d",
"sha256:e50d1de5291d1afd3d660ca149447c682d70b8d3c22f97ed9a3076e6344330b0",
"sha256:e998782d1e466ce5a61cce18f23fd69ba0eeb78069fd2ad59e1a2928a29f952f",
"sha256:ea7d286519eb575f66617805582391e6483e8b33968831331ecd46fe3c7f753f",
"sha256:edbba200696c4be93a10020e4e0eab5ca0898dff4920f3dc2b4d39c14e40b993",
"sha256:f112dcfcbcbb19da33e9218611c51208499d52d74e358f2160e64ccb46e50f07",
"sha256:faced8cc33ee6a272654bb3e570994e1949790ae06579ea485c25849f4e79008"
],
"index": "pypi",
"version": "==0.56.2"
},
"numpy": {
"hashes": [
"sha256:004f0efcb2fe1c0bd6ae1fcfc69cc8b6bf2407e0f18be308612007a0762b4089",
"sha256:09f6b7bdffe57fc61d869a22f506049825d707b288039d30f26a0d0d8ea05164",
"sha256:0ea3f98a0ffce3f8f57675eb9119f3f4edb81888b6874bc1953f91e0b1d4f440",
"sha256:17c0e467ade9bda685d5ac7f5fa729d8d3e76b23195471adae2d6a6941bd2c18",
"sha256:1f27b5322ac4067e67c8f9378b41c746d8feac8bdd0e0ffede5324667b8a075c",
"sha256:22d43376ee0acd547f3149b9ec12eec2f0ca4a6ab2f61753c5b29bb3e795ac4d",
"sha256:2ad3ec9a748a8943e6eb4358201f7e1c12ede35f510b1a2221b70af4bb64295c",
"sha256:301c00cf5e60e08e04d842fc47df641d4a181e651c7135c50dc2762ffe293dbd",
"sha256:39a664e3d26ea854211867d20ebcc8023257c1800ae89773cbba9f9e97bae036",
"sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd",
"sha256:78a63d2df1d947bd9d1b11d35564c2f9e4b57898aae4626638056ec1a231c40c",
"sha256:7cd1328e5bdf0dee621912f5833648e2daca72e3839ec1d6695e91089625f0b4",
"sha256:8355fc10fd33a5a70981a5b8a0de51d10af3688d7a9e4a34fcc8fa0d7467bb7f",
"sha256:8c79d7cf86d049d0c5089231a5bcd31edb03555bd93d81a16870aa98c6cfb79d",
"sha256:91b8d6768a75247026e951dce3b2aac79dc7e78622fc148329135ba189813584",
"sha256:94c15ca4e52671a59219146ff584488907b1f9b3fc232622b47e2cf832e94fb8",
"sha256:98dcbc02e39b1658dc4b4508442a560fe3ca5ca0d989f0df062534e5ca3a5c1a",
"sha256:a64403f634e5ffdcd85e0b12c08f04b3080d3e840aef118721021f9b48fc1460",
"sha256:bc6e8da415f359b578b00bcfb1d08411c96e9a97f9e6c7adada554a0812a6cc6",
"sha256:bdc9febce3e68b697d931941b263c59e0c74e8f18861f4064c1f712562903411",
"sha256:c1ba66c48b19cc9c2975c0d354f24058888cdc674bebadceb3cdc9ec403fb5d1",
"sha256:c9f707b5bb73bf277d812ded9896f9512a43edff72712f31667d0a8c2f8e71ee",
"sha256:d5422d6a1ea9b15577a9432e26608c73a78faf0b9039437b075cf322c92e98e7",
"sha256:e5d5420053bbb3dd64c30e58f9363d7a9c27444c3648e61460c1237f9ec3fa14",
"sha256:e868b0389c5ccfc092031a861d4e158ea164d8b7fdbb10e3b5689b4fc6498df6",
"sha256:efd9d3abe5774404becdb0748178b48a218f1d8c44e0375475732211ea47c67e",
"sha256:f8c02ec3c4c4fcb718fdf89a6c6f709b14949408e8cf2a2be5bfa9c49548fd85",
"sha256:ffcf105ecdd9396e05a8e58e81faaaf34d3f9875f137c7372450baa5d77c9a54"
],
"markers": "python_version >= '3.10'",
"version": "==1.23.3"
},
"opencv-python": {
"hashes": [
"sha256:0dc82a3d8630c099d2f3ac1b1aabee164e8188db54a786abb7a4e27eba309440",
"sha256:5af8ba35a4fcb8913ffb86e92403e9a656a4bff4a645d196987468f0f8947875",
"sha256:6e32af22e3202748bd233ed8f538741876191863882eba44e332d1a34993165b",
"sha256:c5bfae41ad4031e66bb10ec4a0a2ffd3e514d092652781e8b1ac98d1b59f1158",
"sha256:dbdc84a9b4ea2cbae33861652d25093944b9959279200b7ae0badd32439f74de",
"sha256:e6e448b62afc95c5b58f97e87ef84699e6607fe5c58730a03301c52496005cae",
"sha256:f482e78de6e7b0b060ff994ffd859bddc3f7f382bb2019ef157b0ea8ca8712f5"
],
"index": "pypi",
"version": "==4.6.0.66"
},
"setuptools": {
"hashes": [
"sha256:09980778aa734c3037a47997f28d6db5ab18bdf2af0e49f719bfc53967fd2e82",
"sha256:608a7885b664342ae9fafc43840b29d219c5a578876f6f7e00c4e2612160587f"
],
"markers": "python_version >= '3.7'",
"version": "==59.8.0"
}
},
"develop": {}
}

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# Pyrometry image processing
## Temperature maps
**Grayscale pyrometry:** currently basic; uses grayscale opencv import, then just applies a jet filter. Doesn't yet copy the full impl in the paper.
**Ratio pyrometry:** pretty damn close to what's in the paper but it's very broken atm
**Test image:**
![](01-0001.png)
**Grayscale pyrometry result:**
![](01-0001-transformed-grayscale.png)

12
grayscale_pyrometry.py Normal file
View File

@ -0,0 +1,12 @@
import cv2 as cv
import numpy as np
img = cv.imread('01-0001.png', 0)
kernel = np.array([
[0.1, 0.1, 0.1],
[0.1, 1, 0.1],
[0.1, 0.1, 0.1],
])
img = cv.filter2D(src=img, ddepth=-1, kernel=kernel)
img = cv.applyColorMap(img, cv.COLORMAP_JET)
cv.imwrite('01-0001-transformed-grayscale.png', img)

56
ratio_pyrometry.py Normal file
View File

@ -0,0 +1,56 @@
import math
import cv2 as cv
import numpy as np
from numba import jit
# camera settings
I_Darkcurrent = 7.7
exposure_time = 4
f_stop = 5
ISO = 100 # basically brightness
@jit(nopython=True)
def rg_ratio_normalize(imgarr):
imgnew = imgarr
for i in range(len(imgarr)):
for j in range(len(imgarr[i])):
px = imgarr[i][j]
r_norm = normalization_func(px[0])
g_norm = normalization_func(px[1])
# apply camera calibration func
ratio = pyrometry_calibration_formula(g_norm, r_norm)
# remove edge cases
if ratio < 600 or ratio > 1200:
ratio = 0
imgnew[i][j] = [ratio, ratio, ratio]
return imgnew
@jit(nopython=True)
def normalization_func(i):
return (i - I_Darkcurrent) * (f_stop ** 2) / (ISO * exposure_time)
@jit(nopython=True)
def pyrometry_calibration_formula(i_ng, i_nr):
return 362.73 * math.log10(
(i_ng/i_nr) ** 3
) + 2186.7 * math.log10(
(i_ng/i_nr) ** 3
) + 4466.5 * math.log10(
(i_ng / i_nr) ** 3
) + 3753.5
img = cv.imread('01-0001.png')
img = rg_ratio_normalize(img)
kernel = np.array([
[0.1, 0.1, 0.1],
[0.1, 1, 0.1],
[0.1, 0.1, 0.1],
])
img = cv.filter2D(src=img, ddepth=-1, kernel=kernel)
# img = cv.bitwise_not(img)
img = cv.applyColorMap(img, cv.COLORMAP_JET)
cv.imwrite('01-0001-transformed-ratio.png', img)