diff --git a/res/essay/2-5-1_bgr.png b/res/essay/2-5-1_bgr.png new file mode 100644 index 0000000..f75827a Binary files /dev/null and b/res/essay/2-5-1_bgr.png differ diff --git a/res/essay/2-5-1_bgr_expanded.png b/res/essay/2-5-1_bgr_expanded.png new file mode 100644 index 0000000..87a5f31 Binary files /dev/null and b/res/essay/2-5-1_bgr_expanded.png differ diff --git a/res/essay/2-5-1_bgr_histogram.png b/res/essay/2-5-1_bgr_histogram.png new file mode 100644 index 0000000..53b977a Binary files /dev/null and b/res/essay/2-5-1_bgr_histogram.png differ diff --git a/res/essay/2-5-1_hsv.png b/res/essay/2-5-1_hsv.png new file mode 100644 index 0000000..5825d67 Binary files /dev/null and b/res/essay/2-5-1_hsv.png differ diff --git a/res/essay/2-5-1_hsv_expanded.png b/res/essay/2-5-1_hsv_expanded.png new file mode 100644 index 0000000..c474f5a Binary files /dev/null and b/res/essay/2-5-1_hsv_expanded.png differ diff --git a/res/essay/2-5-1_hsv_histogram.png b/res/essay/2-5-1_hsv_histogram.png new file mode 100644 index 0000000..27196ea Binary files /dev/null and b/res/essay/2-5-1_hsv_histogram.png differ diff --git a/src/experiments/algorithms/colourspace.py b/src/experiments/algorithms/colourspace.py index 0667ec9..571d434 100644 --- a/src/experiments/algorithms/colourspace.py +++ b/src/experiments/algorithms/colourspace.py @@ -16,53 +16,68 @@ 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" -# DATASET_PATH = "C:\\Users\\Tom\\Desktop\\Files\\Repositories\\snake-vault\\TREES\\dataset\\" -# full_img = cv2.imread(DATASET_PATH + "alder\\1.jpg", 1) +full_img = cv2.imread(DATASET_PATH + IMAGE, 1) +assert full_img is not None, "Path is wrong: " + DATASET_PATH + IMAGE -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) -# 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]) +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) -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() \ No newline at end of file +plt.show() \ No newline at end of file