2
0
forked from s444420/AL-2020

img to 1d array

This commit is contained in:
shaaqu 2020-05-20 07:32:13 +02:00
parent f8a018ab7d
commit f1ce998628
4 changed files with 73 additions and 12 deletions

View File

@ -19,14 +19,11 @@
<select /> <select />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment=""> <list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="train.py">
<change afterPath="$PROJECT_DIR$/.idea/other.xml" afterDir="false" /> <change afterPath="$PROJECT_DIR$/coder/gr_test.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/coder/scan.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/coder/image.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/coder/test.jpg" 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" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/wozek.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/wozek.iml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/coder/test.jpg" beforeDir="false" afterPath="$PROJECT_DIR$/coder/test.jpg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assiging/feature_hashing.py" 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" />
@ -70,6 +67,7 @@
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
@ -150,6 +148,25 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="image" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" />
<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$/coder/image.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="true" />
<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="main" type="PythonConfigurationType" factoryName="Python" temporary="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="wozek" /> <module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -196,10 +213,12 @@
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" /> <item itemvalue="Python.feature_hashing" />
<item itemvalue="Python.train" /> <item itemvalue="Python.train" />
<item itemvalue="Python.image" />
</list> </list>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.train" /> <item itemvalue="Python.train" />
<item itemvalue="Python.image" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" /> <item itemvalue="Python.feature_hashing" />
<item itemvalue="Python.board" /> <item itemvalue="Python.board" />
@ -228,7 +247,7 @@
<workItem from="1589814601057" duration="4208000" /> <workItem from="1589814601057" duration="4208000" />
<workItem from="1589844260514" duration="777000" /> <workItem from="1589844260514" duration="777000" />
<workItem from="1589845066174" duration="177000" /> <workItem from="1589845066174" duration="177000" />
<workItem from="1589888090669" duration="11020000" /> <workItem from="1589888090669" duration="16639000" />
</task> </task>
<task id="LOCAL-00001" summary="create Shelf"> <task id="LOCAL-00001" summary="create Shelf">
<created>1589815443652</created> <created>1589815443652</created>
@ -251,7 +270,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1589822196451</updated> <updated>1589822196451</updated>
</task> </task>
<option name="localTasksCounter" value="4" /> <task id="LOCAL-00004" summary="train.py">
<created>1589918562733</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1589918562733</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -270,12 +296,18 @@
<option name="oldMeFiltersMigrated" value="true" /> <option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="create Shelf" /> <MESSAGE value="create Shelf" />
<MESSAGE value="create addShelf method in Field class" /> <MESSAGE value="create addShelf method in Field class" />
<MESSAGE value="changed CreateDataSweets to lowercase" /> <MESSAGE value="changed CreateDataSweets to lowercase" />
<option name="LAST_COMMIT_MESSAGE" value="changed CreateDataSweets to lowercase" /> <MESSAGE value="train.py" />
<option name="LAST_COMMIT_MESSAGE" value="train.py" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="115" y="162" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589923610328">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="115" y="162" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1536.824@0.0.1536.824" timestamp="1589923610328" />
<state width="1493" height="208" key="GridCell.Tab.0.bottom" timestamp="1589845242796"> <state width="1493" height="208" key="GridCell.Tab.0.bottom" timestamp="1589845242796">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
@ -296,10 +328,10 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1589845139218" /> <state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1589845139218" />
<state x="54" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589902389638"> <state x="54" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589918982407">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="54" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1589902389638" /> <state x="54" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1589918982407" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/AL_2020$feature_hashing.coverage" NAME="feature_hashing Coverage Results" MODIFIED="1589823737949" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Assiging" /> <SUITE FILE_PATH="coverage/AL_2020$feature_hashing.coverage" NAME="feature_hashing Coverage Results" MODIFIED="1589823737949" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Assiging" />

BIN
coder/gr_test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

29
coder/image.py Normal file
View File

@ -0,0 +1,29 @@
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import cv2
img = cv2.cvtColor(cv2.imread('test.jpg'), cv2.COLOR_BGR2GRAY)
img = cv2.GaussianBlur(img, (15, 15), 0) # poprawia jakosc
img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA)
print(type(img))
print(img.shape)
print(img)
plt.imshow(img ,cmap='binary')
plt.show()
data = []
rows, cols = img.shape
for i in range(rows):
for j in range(cols):
k = img[i, j]
if k > 200:
k = 0 # brak czarnego
else:
k = 1
data.append(k)
print(data)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB