added colorband
This commit is contained in:
Generated
+4
-2
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
<orderEntry type="inheritedJdk" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.12 (chromakey)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
Generated
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (cv)" project-jdk-type="Python SDK" />
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.12 (chromakey)" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (chromakey)" project-jdk-type="Python SDK" />
|
||||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+68
-54
@@ -1,7 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="03a3dd8f-6322-46a9-91ac-da33c526d3ed" name="Default Changelist" comment="" />
|
<list default="true" id="03a3dd8f-6322-46a9-91ac-da33c526d3ed" name="Default Changelist" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/color_band.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/chromakey.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/chromakey.iml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@@ -14,19 +23,33 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 1
|
||||||
|
}</component>
|
||||||
<component name="ProjectId" id="1ij6srjKxzA0W3XYK7oJbOmnwep" />
|
<component name="ProjectId" id="1ij6srjKxzA0W3XYK7oJbOmnwep" />
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">{
|
||||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
"keyToString": {
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
"Python.chromakey.executor": "Run",
|
||||||
<property name="settings.editor.selected.configurable" value="configurable.group.appearance" />
|
"Python.color_band.executor": "Run",
|
||||||
</component>
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
<component name="RunManager" selected="Python.chromakey">
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
|
"git-widget-placeholder": "master",
|
||||||
|
"last_opened_file_path": "/home/jens/work/chromakey",
|
||||||
|
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="RunManager" selected="Python.color_band">
|
||||||
<configuration name="chromakey" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
<configuration name="chromakey" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
<module name="chromakey" />
|
<module name="chromakey" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
@@ -38,7 +61,29 @@
|
|||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/chromakey.py" />
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/chromakey.py" />
|
||||||
<option name="PARAMETERS" value="-f $PROJECT_DIR$/chromatest.png" />
|
<option name="PARAMETERS" value="-f $PROJECT_DIR$/sample.png" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="color_band" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="chromakey" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/color_band.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
<option name="EMULATE_TERMINAL" value="false" />
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
<option name="MODULE_MODE" value="false" />
|
<option name="MODULE_MODE" value="false" />
|
||||||
@@ -48,6 +93,7 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
<module name="chromakey" />
|
<module name="chromakey" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
@@ -69,14 +115,23 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Python.main" />
|
<item itemvalue="Python.main" />
|
||||||
|
<item itemvalue="Python.color_band" />
|
||||||
<item itemvalue="Python.chromakey" />
|
<item itemvalue="Python.chromakey" />
|
||||||
</list>
|
</list>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
|
<item itemvalue="Python.color_band" />
|
||||||
<item itemvalue="Python.chromakey" />
|
<item itemvalue="Python.chromakey" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="SharedIndexes">
|
||||||
|
<attachedChunks>
|
||||||
|
<set>
|
||||||
|
<option value="bundled-python-sdk-4f4e415b4190-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.26053.29" />
|
||||||
|
</set>
|
||||||
|
</attachedChunks>
|
||||||
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
<task active="true" id="Default" summary="Default task">
|
<task active="true" id="Default" summary="Default task">
|
||||||
@@ -88,52 +143,6 @@
|
|||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="WindowStateProjectService">
|
|
||||||
<state x="621" y="294" width="732" height="644" key="#Inspections" timestamp="1602414363028">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state x="621" y="294" width="732" height="644" key="#Inspections/64.26.1856.1174@64.26.1856.1174" timestamp="1602414363028" />
|
|
||||||
<state x="161" y="194" width="1427" height="684" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1602518054229">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state x="161" y="194" width="1427" height="684" key="#com.intellij.execution.impl.EditConfigurationsDialog/64.26.1856.1174@64.26.1856.1174" timestamp="1602518054229" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.bottom" timestamp="1602605534222">
|
|
||||||
<screen x="64" y="27" width="1856" height="1173" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="315" key="GridCell.Tab.0.bottom/64.26.1856.1174@64.26.1856.1174" timestamp="1602518339857" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.bottom/64.27.1856.1173@64.27.1856.1173" timestamp="1602605534222" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.center" timestamp="1602605534222">
|
|
||||||
<screen x="64" y="27" width="1856" height="1173" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="315" key="GridCell.Tab.0.center/64.26.1856.1174@64.26.1856.1174" timestamp="1602518339857" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.center/64.27.1856.1173@64.27.1856.1173" timestamp="1602605534222" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.left" timestamp="1602605534221">
|
|
||||||
<screen x="64" y="27" width="1856" height="1173" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="315" key="GridCell.Tab.0.left/64.26.1856.1174@64.26.1856.1174" timestamp="1602518339857" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.left/64.27.1856.1173@64.27.1856.1173" timestamp="1602605534221" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.right" timestamp="1602605534222">
|
|
||||||
<screen x="64" y="27" width="1856" height="1173" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="315" key="GridCell.Tab.0.right/64.26.1856.1174@64.26.1856.1174" timestamp="1602518339857" />
|
|
||||||
<state width="1833" height="314" key="GridCell.Tab.0.right/64.27.1856.1173@64.27.1856.1173" timestamp="1602605534222" />
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.bottom" timestamp="1602436299537">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.bottom/64.26.1856.1174@64.26.1856.1174" timestamp="1602436299537" />
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.center" timestamp="1602436299536">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.center/64.26.1856.1174@64.26.1856.1174" timestamp="1602436299536" />
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.left" timestamp="1602436299536">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.left/64.26.1856.1174@64.26.1856.1174" timestamp="1602436299536" />
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.right" timestamp="1602436299536">
|
|
||||||
<screen x="64" y="26" width="1856" height="1174" />
|
|
||||||
</state>
|
|
||||||
<state width="1833" height="388" key="GridCell.Tab.1.right/64.26.1856.1174@64.26.1856.1174" timestamp="1602436299536" />
|
|
||||||
</component>
|
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
<breakpoints>
|
<breakpoints>
|
||||||
@@ -142,6 +151,11 @@
|
|||||||
<line>8</line>
|
<line>8</line>
|
||||||
<option name="timeStamp" value="1" />
|
<option name="timeStamp" value="1" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
|
<url>file://$PROJECT_DIR$/color_band.py</url>
|
||||||
|
<line>39</line>
|
||||||
|
<option name="timeStamp" value="41" />
|
||||||
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
from pickletools import uint8
|
||||||
|
|
||||||
|
import cv2 as cv
|
||||||
|
import numpy as np
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
|
||||||
|
def key_ish(kid: int, color: np.array):
|
||||||
|
prg = [(1,2), (0,2), (0,1)]
|
||||||
|
res = 0
|
||||||
|
|
||||||
|
c = prg[kid]
|
||||||
|
ci1 = c[0]
|
||||||
|
ci2 = c[1]
|
||||||
|
c1 = color[ci1]
|
||||||
|
c2 = color[ci2]
|
||||||
|
k0_1 = color[kid]
|
||||||
|
k0_2 = color[kid]
|
||||||
|
k0_12 = color[kid]
|
||||||
|
s12 = c1 + c2
|
||||||
|
if c1 > 0:
|
||||||
|
k0_1 = color[kid] / c1
|
||||||
|
if c2 > 0:
|
||||||
|
k0_2 = color[kid] / c2
|
||||||
|
if s12 > 0:
|
||||||
|
k0_12 = color[kid] / s12
|
||||||
|
|
||||||
|
# if s12 > 2*c1 and s12 > 2*c2:
|
||||||
|
# res = k0_12
|
||||||
|
|
||||||
|
if c1 > c2:
|
||||||
|
res = k0_1
|
||||||
|
else:
|
||||||
|
res = k0_2
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
def despill(src, key_color, mat: float):
|
||||||
|
result = np.copy(src)
|
||||||
|
|
||||||
|
result[:, :, 0] -= (1-mat)*key_color[:, :, 0]
|
||||||
|
result[:, :, 1] -= (1-mat)*key_color[:, :, 1]
|
||||||
|
result[:, :, 2] -= (1-mat)*key_color[:, :, 2]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def main():
|
||||||
|
key_index = 1
|
||||||
|
key_bgr = np.float32([[[0, 0, 0]]])
|
||||||
|
key_bgr[:,:,key_index] = 1
|
||||||
|
|
||||||
|
orig = np.ones([200, 360, 3], dtype=np.float32)
|
||||||
|
for x, hn in enumerate(np.linspace(0, 1, 360)):
|
||||||
|
for y in range(200):
|
||||||
|
s = y/200
|
||||||
|
orig_hsv = np.float32([[[hn * 360, s, 1]]])
|
||||||
|
orig_bgr = cv.cvtColor(orig_hsv, cv.COLOR_HSV2BGR)
|
||||||
|
orig[y, x] = orig_bgr
|
||||||
|
|
||||||
|
cv.imshow("orig", orig)
|
||||||
|
|
||||||
|
k_tol = 0.3
|
||||||
|
k_boost = 1.5
|
||||||
|
_x = []
|
||||||
|
_y = []
|
||||||
|
pic = np.ones([200, 360, 3], dtype=np.float32)
|
||||||
|
mat = np.ones([200, 360, 1], dtype=np.float32)
|
||||||
|
for x, hn in enumerate(np.linspace(0, 1, 360)):
|
||||||
|
_x.append(x)
|
||||||
|
v = 0
|
||||||
|
for y in range(200):
|
||||||
|
s = y/200
|
||||||
|
spec_hsv = np.float32([[[hn * 360, s, 1]]])
|
||||||
|
spec_bgr = cv.cvtColor(np.array(spec_hsv, dtype=np.float32),cv.COLOR_HSV2BGR)
|
||||||
|
v0 = spec_bgr[0,0,:]
|
||||||
|
v1 = min(1.0, k_boost * (1.0 - min(1.0, k_tol*key_ish(key_index, v0))))
|
||||||
|
pic_hsv = np.float32([[[hn*360,s,v1]]])
|
||||||
|
pic_bgr = cv.cvtColor(pic_hsv,cv.COLOR_HSV2BGR)
|
||||||
|
pic_bgr = despill(pic_bgr, key_bgr, v1)
|
||||||
|
pic[y, x] = pic_bgr
|
||||||
|
mat[y, x] = v1
|
||||||
|
_y.append(v1)
|
||||||
|
print(mat)
|
||||||
|
cv.imshow("pic", pic)
|
||||||
|
cv.imshow("mat", mat)
|
||||||
|
|
||||||
|
plt.plot(_x, _y)
|
||||||
|
plt.grid()
|
||||||
|
# plt.show()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
ch = cv.waitKey()
|
||||||
Reference in New Issue
Block a user