main
Jan-Niclas Loosen 10 months ago
parent 8e3db2af40
commit 076f19cd27

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module version="4"> <module type="PYTHON_MODULE" version="4">
<component name="PyDocumentationSettings"> <component name="NewModuleRootManager">
<option name="format" value="GOOGLE" /> <content url="file://$MODULE_DIR$">
<option name="myDocStringFormat" value="Google" /> <excludeFolder url="file://$MODULE_DIR$/Virtualenv" />
</content>
<orderEntry type="jdk" jdkName="C:\ProgramData\anaconda3" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JupyterPersistentConnectionParameters">
<option name="moduleParameters">
<map>
<entry key="$USER_HOME$/AppData/Local/Temp/01U_Interpolation_A.ipynb/.idea/01U_Interpolation_A.ipynb.iml">
<value>
<JupyterConnectionParameters>
<option name="managed" value="true" />
<option name="port" value="8008" />
</JupyterConnectionParameters>
</value>
</entry>
<entry key="$USER_HOME$/Nextcloud/_Container/Hausaufgaben/Uebung_Numerik_Prog/.idea/Uebung_Numerik_Prog.iml">
<value>
<JupyterConnectionParameters>
<option name="managed" value="true" />
<option name="sdkHomePath" value="C:\Users\janni\AppData\Local\Microsoft\WindowsApps\python3.10.exe" />
</JupyterConnectionParameters>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -1,4 +1,4 @@
<?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="C:\Users\janni\anaconda3" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="C:\ProgramData\anaconda3" project-jdk-type="Python SDK" />
</project> </project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/UNI_Python.iml" filepath="$PROJECT_DIR$/.idea/UNI_Python.iml" />
</modules>
</component>
</project>

@ -4,11 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c8162e9c-0010-43df-bfbc-c294a3a64a5d" name="Changes" comment=""> <list default="true" id="42ed9a51-9564-48c5-b5fa-035301b1578d" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/ha_08/loosen_janniclas_1540907_09.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ha_08/next_generation.jpg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/UNI_Python.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/UNI_Python.iml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/UNI_Python.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/UNI_Python.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/jupyter-settings.xml" beforeDir="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" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ha_08/edited.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/ha_08/loosen_janniclas_1540907_09.py" beforeDir="false" afterPath="$PROJECT_DIR$/ha_08/loosen_janniclas_1540907_09.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ha_08/next_generation.jpg" beforeDir="false" />
</list> </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" />
@ -18,83 +21,32 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="ProjectId" id="2YitccTSlklP0ogYm4Iys53zq5P" /> <component name="ProjectId" id="2ad23KMVrbf8YEYMjvnrmBZ8MSS" />
<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">{
&quot;keyToString&quot;: { &quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;, &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;, &quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Universitaet/UNI_Syssoft&quot;, &quot;last_opened_file_path&quot;: &quot;C:/Universitaet/UNI_Python&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;, &quot;python.debugger.dataview.coloredbydefault&quot;: &quot;false&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}</component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Universitaet\UNI_Python\ha_06" />
</key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="C:\Universitaet\UNI_Python\ha_08" /> <recent name="C:\Universitaet\UNI_Python\ueb_01" />
<recent name="C:\Universitaet\UNI_Python\ha_07" />
<recent name="C:\Universitaet\UNI_Python\ha_04" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.loosen_janniclas_1540907_09"> <component name="RunManager" selected="Python.loosen_janniclas_1540907_09 (1)">
<configuration name="loosen_janniclas_1540907_07" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="loosen_janniclas_1540907_09 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="UNI_Python" />
<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$/ha_06" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/ha_06/loosen_janniclas_1540907_07.py" />
<option name="PARAMETERS" value="" />
<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="loosen_janniclas_1540907_08" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="UNI_Python" />
<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$/ha_07" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/ha_07/loosen_janniclas_1540907_08.py" />
<option name="PARAMETERS" value="" />
<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="loosen_janniclas_1540907_09" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="UNI_Python" /> <module name="UNI_Python" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
@ -116,7 +68,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="loosen_janniclas_1540907_09" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="UNI_Python" /> <module name="UNI_Python" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
@ -124,12 +76,12 @@
<env name="PYTHONUNBUFFERED" value="1" /> <env name="PYTHONUNBUFFERED" value="1" />
</envs> </envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/phising" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/ha_08" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<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" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/phising/test.py" /> <option name="SCRIPT_NAME" value="C:\Universitaet\UNI_Python\ueb_01\loosen_janniclas_1540907_09.py" />
<option name="PARAMETERS" value="" /> <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" />
@ -138,51 +90,25 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="Python tests in loosen_janniclas_1540907_08.py" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
<module name="UNI_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/ha_07" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/ha_07/loosen_janniclas_1540907_08.py&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.loosen_janniclas_1540907_09 (1)" />
<item itemvalue="Python.loosen_janniclas_1540907_09" /> <item itemvalue="Python.loosen_janniclas_1540907_09" />
<item itemvalue="Python.test" />
<item itemvalue="Python.loosen_janniclas_1540907_08" />
<item itemvalue="Python tests.Python tests in loosen_janniclas_1540907_08.py" />
<item itemvalue="Python.loosen_janniclas_1540907_07" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </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">
<changelist id="c8162e9c-0010-43df-bfbc-c294a3a64a5d" name="Changes" comment="" /> <changelist id="42ed9a51-9564-48c5-b5fa-035301b1578d" name="Changes" comment="" />
<created>1701020308079</created> <created>1704633934437</created>
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1701020308079</updated> <updated>1704633934437</updated>
<workItem from="1701020309178" duration="156000" /> <workItem from="1704633935452" duration="1454000" />
<workItem from="1701163646587" duration="660000" /> <workItem from="1704635406869" duration="1345000" />
<workItem from="1701177311506" duration="2378000" /> <workItem from="1704710482778" duration="867000" />
<workItem from="1701179783052" duration="66000" /> <workItem from="1704711379198" duration="6462000" />
<workItem from="1701623797251" duration="4657000" />
<workItem from="1701682053076" duration="3736000" />
<workItem from="1701687608304" duration="4000" />
<workItem from="1702139628432" duration="605000" />
<workItem from="1702234189891" duration="15000" />
<workItem from="1702839799586" duration="8899000" />
<workItem from="1703717324053" duration="344000" />
<workItem from="1704450546759" duration="12235000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -190,13 +116,7 @@
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/UNI_Python$test.coverage" NAME="test Coverage Results" MODIFIED="1703717628775" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/phising" /> <SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_09__1_.coverage" NAME="loosen_janniclas_1540907_09 (1) Coverage Results" MODIFIED="1704717881190" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_08" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_05.coverage" NAME="loosen_janniclas_1540907_05 Coverage Results" MODIFIED="1701179684140" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_04" /> <SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_09.coverage" NAME="loosen_janniclas_1540907_09 Coverage Results" MODIFIED="1704711219437" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_08" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_03.coverage" NAME="loosen_janniclas_1540907_03 Coverage Results" MODIFIED="1701179808579" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_02" />
<SUITE FILE_PATH="coverage/UNI_Python$.coverage" NAME=" Coverage Results" MODIFIED="1702844032914" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_07" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_06.coverage" NAME="loosen_janniclas_1540907_06 Coverage Results" MODIFIED="1701787405612" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_05" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_08.coverage" NAME="loosen_janniclas_1540907_08 Coverage Results" MODIFIED="1702853587791" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_07" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_07.coverage" NAME="loosen_janniclas_1540907_07 Coverage Results" MODIFIED="1702140187482" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_06" />
<SUITE FILE_PATH="coverage/UNI_Python$loosen_janniclas_1540907_09.coverage" NAME="loosen_janniclas_1540907_09 Coverage Results" MODIFIED="1704469430043" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ha_08" />
</component> </component>
</project> </project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

@ -1,9 +1,10 @@
import colorsys import colorsys
import plotly.graph_objects as go from io import BytesIO
import requests
from PIL import Image from PIL import Image
import numpy as np import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
import time
def apply_convolution_operator(operator, image): def apply_convolution_operator(operator, image):
@ -74,41 +75,41 @@ laplace = np.array([
[0, 1, 0] [0, 1, 0]
]) ])
""" sharp = np.array([
url = "https://cdn.prod.www.spiegel.de/images/9f9be1b3-ac0e-49f9-acbd-a809a102f9b6_w960_r1.778_fpx39_fpy30.jpg" [0, -1, 0],
[-1, 5, -1],
[0, -1, 0]
])
url = "https://media.newyorker.com/photos/5e3b18f932d7150008e6cf16/master/w_2240,c_limit/Neima-Picard.jpg"
response = requests.get(url) response = requests.get(url)
if response.status_code == 200: if response.status_code == 200:
# image = Image.open(BytesIO(response.content)) image = Image.open(BytesIO(response.content))
image = Image.open("next_generation.jpg") operators = [g1, g2, g3, g4]
operators = [laplace]
edited_image = image
for operator in operators: for operator in operators:
edited_image = apply_convolution_operator(operator, edited_image) image_edited = apply_convolution_operator(operator, image)
edited_image = edited_image.convert("RGB") # Convert to RGB mode image_edited.show()
edited_image.show()
edited_image.save("edited.jpg")
else: else:
print(f"Failed to download image. Status code: {response.status_code}") print(f"Failed to download image. Status code: {response.status_code}")
"""
class Heatmap_Simulator: class Heatmap_Simulator:
k = 1 k, h, delta_f = 1, 0.01, 0.05
h = 2 # Add more accurate cooling effect:
delta_f = 0.005 # tmp_min, tmp_max, env = -0.5, 1, -0.5
tmp_min, tmp_max, env = 0, 1, 0
cookie_size = 0.5 cookie_size = 0.5
def __init__(self, y_size=28, x_size=28, tmp_min=0, tmp_max=1): def __init__(self, y_size=28, x_size=28):
init_heatmap = np.zeros((y_size, x_size)) init_heatmap = np.full((y_size, x_size), self.tmp_min)
self.x_size = x_size self.x_size = x_size
self.y_size = y_size self.y_size = y_size
self.tmp_min = tmp_min
self.tmp_max = tmp_max
size = self.cookie_size / 2 size = self.cookie_size / 2
for y in range(int(y_size * (0.5 - size)), int(y_size * (0.5 + size))): for y in range(int(y_size * (0.5 - size)), int(y_size * (0.5 + size))):
for x in range(int(x_size * (0.5 - size)), int(x_size * (0.5 + size))): for x in range(int(x_size * (0.5 - size)), int(x_size * (0.5 + size))):
init_heatmap[y][x] = 1 init_heatmap[y][x] = self.tmp_max
self.heatmap = init_heatmap self.heatmap = init_heatmap
def simulate(self, cycles=1): def simulate(self, cycles=1):
@ -123,10 +124,10 @@ class Heatmap_Simulator:
self.heatmap = new_heatmap self.heatmap = new_heatmap
def _consider_convolution(self, x, y): def _consider_convolution(self, x, y):
top = self.heatmap[y - 1, x] if y > 0 else 0 top = self.heatmap[y - 1, x] if y > 0 else self.env
bottom = self.heatmap[y + 1, x] if y < self.heatmap.shape[0] - 1 else 0 bottom = self.heatmap[y + 1, x] if y < self.heatmap.shape[0] - 1 else self.env
left = self.heatmap[y, x - 1] if x > 0 else 0 left = self.heatmap[y, x - 1] if x > 0 else self.env
right = self.heatmap[y, x + 1] if x < self.heatmap.shape[1] - 1 else 0 right = self.heatmap[y, x + 1] if x < self.heatmap.shape[1] - 1 else self.env
center = self.heatmap[y, x] center = self.heatmap[y, x]
return top + bottom + left + right + center * (-4) return top + bottom + left + right + center * (-4)
@ -138,8 +139,8 @@ class Heatmap_Simulator:
class Visual_Heatmap_Simulator(Heatmap_Simulator): class Visual_Heatmap_Simulator(Heatmap_Simulator):
def __init__(self, y_size=28, x_size=28, tmp_min=0, tmp_max=1, delay=0.5): def __init__(self, y_size=28, x_size=28, delay=0.5):
super().__init__(y_size, x_size, tmp_min, tmp_max) super().__init__(y_size, x_size)
self.delay = delay self.delay = delay
def simulate_visual(self, cycles=100, skip=5): def simulate_visual(self, cycles=100, skip=5):
@ -151,15 +152,11 @@ class Visual_Heatmap_Simulator(Heatmap_Simulator):
print(f"Figure updated: {c}.") print(f"Figure updated: {c}.")
def _update_plot(self): def _update_plot(self):
plt.imshow(self.heatmap, cmap='viridis', interpolation='nearest') plt.imshow(self.heatmap, cmap='viridis', interpolation='nearest', vmin=self.tmp_min, vmax=self.tmp_max)
plt.draw() plt.draw()
plt.pause(self.delay) plt.pause(self.delay)
simulator = Visual_Heatmap_Simulator(28, 28, -0.5, 1)
simulator.simulate_visual(10000, 50)
class Heatmap_Image: class Heatmap_Image:
def __init__(self, heatmap, min_val, max_val): def __init__(self, heatmap, min_val, max_val):
self.min_val = min_val self.min_val = min_val
@ -183,3 +180,14 @@ class Heatmap_Image:
def save(self, file): def save(self, file):
self.image.save(file) self.image.save(file)
"""
sim = Heatmap_Simulator()
img = sim.export()
img.save("img_0.jpg")
for i in range(1,20):
sim.simulate(100)
img = sim.export()
img.save(f"img_{i}.jpg")
"""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Loading…
Cancel
Save