Compare commits

..

No commits in common. "5aba28b120bd6f3e3457ee407c2473ec3daefcee" and "8e7f1b57f157c738cc90e1e38453c76de043e0d0" have entirely different histories.

7 changed files with 20 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

View File

@ -16,68 +16,53 @@ def histNormalize(hist):
for i in range(len(hist)):
hist[i][0] = (hist[i][0] - min_val)/(max_val - min_val)
DATASET_PATH = "C:\\Users\\Tom\\Desktop\\Files\\Repositories\\EV5_Beeldherk_Bomen\\res\\trees\\"
SAVE_PATH = "C:\\Users\\Tom\\Desktop\\Files\\Repositories\\EV5_Beeldherk_Bomen\\res\\essay\\"
IMAGE = "berk_sq1_original.png"
full_img = cv2.imread(DATASET_PATH + IMAGE, 1)
assert full_img is not None, "Path is wrong: " + DATASET_PATH + IMAGE
# DATASET_PATH = "C:\\Users\\Tom\\Desktop\\Files\\Repositories\\snake-vault\\TREES\\dataset\\"
# full_img = cv2.imread(DATASET_PATH + "alder\\1.jpg", 1)
DATASET_PATH = "..\\..\\..\\res\\trees\\"
full_img = cv2.imread(DATASET_PATH + "berk_sq1_original.png", 1)
assert full_img is not None, "Path is wrong"
bgr_img = cv2.resize(full_img, (0, 0), fx=0.25, fy=0.25)
hsv_img = cv2.cvtColor(bgr_img, cv2.COLOR_BGR2HSV)
cv2.imshow('BGR', bgr_img)
BGR = np.concatenate((bgr_img[:, :, 0], bgr_img[:, :, 1], bgr_img[:, :, 2]),
axis=1)
cv2.imshow("BGR - Expanded", BGR)
cv2.imshow('HSV', hsv_img)
HSV = np.concatenate((hsv_img[:, :, 0], hsv_img[:, :, 1], hsv_img[:, :, 2]),
axis=1)
cv2.imshow("HSV - Expanded", HSV)
cv2.imwrite(SAVE_PATH + "2-5-1_bgr.png", bgr_img)
cv2.imwrite(SAVE_PATH + "2-5-1_bgr_expanded.png", BGR)
cv2.imwrite(SAVE_PATH + "2-5-1_hsv.png", hsv_img)
cv2.imwrite(SAVE_PATH + "2-5-1_hsv_expanded.png", HSV)
# cv2.imshow('BGR',bgr_img)
# cv2.imshow('HSV',hsv_img)
# cv2.imshow('HSV - H',hsv_img[:, :, 0])
# cv2.imshow('HSV - S',hsv_img[:, :, 1])
# cv2.imshow('HSV - V',hsv_img[:, :, 2])
print("BGR")
mean, std = imgStats(bgr_img)
print(mean)
print(std)
print()
mean, std = imgStats(hsv_img)
print(mean)
print(std)
print()
cv2.waitKey(0)
cv2.destroyAllWindows()
hist = cv2.calcHist([bgr_img], [0], None, [256], [0,256])
plt.plot(hist, label='B', c='b')
hist = cv2.calcHist([bgr_img], [1], None, [256], [0,256])
plt.plot(hist, label='G', c='g')
hist = cv2.calcHist([bgr_img], [2], None, [256], [0,256])
plt.plot(hist, label='R', c='r')
plt.title("BGR histogram")
plt.xlabel("Waarde van pixels [0-255]")
plt.ylabel("Hoeveelheid pixels")
plt.grid()
plt.legend()
plt.show()
print("HSV")
mean, std = imgStats(hsv_img)
print(mean)
print(std)
hist = cv2.calcHist([hsv_img], [0], None, [256], [0,256])
plt.plot(hist, label='H')
hist = cv2.calcHist([hsv_img], [1], None, [256], [0,256])
plt.plot(hist, label='S')
hist = cv2.calcHist([hsv_img], [2], None, [256], [0,256])
plt.plot(hist, label='V')
plt.title("HSV histogram")
plt.xlabel("Waarde van pixels [0-255]")
plt.ylabel("Hoeveelheid pixels")
plt.grid()
plt.legend()
plt.show()
cv2.waitKey(0)
cv2.destroyAllWindows()