utworzone pliki projektu indywidualnego

This commit is contained in:
Adam Osiowy 2020-05-12 00:58:26 +02:00
parent e06cbf4acd
commit 57381d630a
48 changed files with 70 additions and 0 deletions

BIN
etykiety.h5 Normal file

Binary file not shown.

BIN
parametry_zdjec.h5 Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

70
tworzenie_danych_AO.py Normal file
View File

@ -0,0 +1,70 @@
from sklearn.preprocessing import LabelEncoder
import numpy as np
import mahotas
import cv2
import os
import h5py
rozmiar_zdj = tuple((500, 500))
sciezka_do_zdj = "resources/smieci_stare"
h5_dane = 'parametry_zdjec.h5'
h5_etykiety = 'etykiety.h5'
def hu_moments(zdj):
zdj = cv2.cvtColor(zdj, cv2.COLOR_BGR2GRAY)
momenty = cv2.HuMoments(cv2.moments(zdj)).flatten()
return momenty
def haralick(zdj):
szare_zdj = cv2.cvtColor(zdj, cv2.COLOR_BGR2GRAY)
haralick = mahotas.features.haralick(szare_zdj).mean(axis=0)
return haralick
def histogram(zdj, mask=None):
zdj = cv2.cvtColor(zdj, cv2.COLOR_BGR2HSV)
hist = cv2.calcHist([zdj], [0, 1, 2], mask, [8, 8, 8], [0, 256, 0, 256, 0, 256])
cv2.normalize(hist, hist)
return hist.flatten()
klasy = os.listdir(sciezka_do_zdj)
klasy.sort()
dane = []
wszystkie_typy_zdj = []
for klasa in klasy:
katalog = os.path.join(sciezka_do_zdj, klasa)
biezaca_klasa = klasa
for plik in os.listdir(katalog):
zdj = cv2.imread(os.path.join(katalog, plik))
zdj = cv2.resize(zdj, rozmiar_zdj)
fv_hu_moments = hu_moments(zdj)
fv_haralick = haralick(zdj)
fv_histogram = histogram(zdj)
wiersz = np.hstack([fv_hu_moments, fv_histogram, fv_haralick])
wszystkie_typy_zdj.append(biezaca_klasa)
dane.append(wiersz)
print(len(wszystkie_typy_zdj))
targetNames = np.unique(wszystkie_typy_zdj)
print(targetNames,targetNames.shape)
le = LabelEncoder()
target = le.fit_transform(wszystkie_typy_zdj)
print(target.shape)
h5f_data = h5py.File(h5_dane, 'w')
h5f_data.create_dataset('dataset_1', data=np.array(dane))
h5f_label = h5py.File(h5_etykiety, 'w')
h5f_label.create_dataset('dataset_1', data=np.array(target))
h5f_data.close()
h5f_label.close()