From 423d4ee57dcd0f6c3db39ef2896e542a009a783a Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 23 Oct 2023 16:09:08 -0400 Subject: [PATCH] Convert works but is NOT LOSSLESS --- py/comparison_comparison.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/py/comparison_comparison.py b/py/comparison_comparison.py index e0e4d15..e372aa9 100644 --- a/py/comparison_comparison.py +++ b/py/comparison_comparison.py @@ -2,10 +2,19 @@ import cv2 import numpy as np class ComparisonComparison: - def convert_color (self, color, color_space) : + def __init__ (self) : + c = [0, 0, 255] + print(c) + cc = self.convert_color(c, cv2.COLOR_BGR2RGB, cv2.COLOR_RGB2LAB) + print(cc) + print(self.convert_color(cc, cv2.COLOR_BGR2LAB, cv2.COLOR_LAB2RGB)) + + + def convert_color (self, color, color_space_a, color_space_b) : pixel = np.zeros([1, 1, 3], dtype=np.uint8) + pixel = cv2.cvtColor(pixel, color_space_a) pixel[:] = color - cvt = cv2.cvtColor(pixel, color_space) + cvt = cv2.cvtColor(pixel, color_space_b) return cvt[0, 0] if __name__ == "__main__":