2020-05-20 07:32:13 +02:00
|
|
|
import numpy as np
|
|
|
|
from PIL import Image
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
|
2020-05-20 07:36:18 +02:00
|
|
|
def image():
|
|
|
|
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)
|
2020-05-20 07:32:13 +02:00
|
|
|
|
2020-05-20 07:36:18 +02:00
|
|
|
print(type(img))
|
|
|
|
print(img.shape)
|
|
|
|
print(img)
|
|
|
|
plt.imshow(img, cmap='binary')
|
|
|
|
plt.show()
|
2020-05-20 07:32:13 +02:00
|
|
|
|
2020-05-20 07:36:18 +02:00
|
|
|
data = []
|
2020-05-20 07:32:13 +02:00
|
|
|
|
2020-05-20 07:36:18 +02:00
|
|
|
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
|
2020-05-20 07:32:13 +02:00
|
|
|
|
2020-05-20 07:36:18 +02:00
|
|
|
data.append(k)
|
|
|
|
|
|
|
|
print(data)
|