def test_to_hue_vs_old(): img = _img() hue_new = nphusl.to_hue(img) for row in range(img.shape[0]): for col in range(img.shape[1]): husl_old = _ref_to_husl(img[row, col]) diff = 5.0 if husl_old[1] < 1 else 0.1 _diff(hue_new[row, col], husl_old[0], diff=diff)
def test_to_hue_vs_old(): img = _img() rgb_arr = img * 255 hue_new = nphusl.to_hue(rgb_arr) for row in range(rgb_arr.shape[0]): for col in range(rgb_arr.shape[1]): husl_old = husl.rgb_to_husl(*img[row, col]) diff = 5.0 if husl_old[1] < 1 else 0.0001 assert _diff(hue_new[row, col], husl_old[0], diff=diff)
def test_to_hue_gray(): img = _img() img[..., 1] = img[..., 0] img[..., 2] = img[..., 0] rgb_arr = img[..., 0] * 255 # single channel hue_new = nphusl.to_hue(rgb_arr) for row in range(rgb_arr.shape[0]): for col in range(rgb_arr.shape[1]): hue_old = husl.rgb_to_husl(*img[row, col]) diff = 5.0 if hue_old[1] < 1 else 0.0001 assert _diff(hue_new[row, col], hue_old[0], diff=diff)
def test_to_hue_gray(): img = _img() img = transform.ensure_rgb_float(img) img[..., 1] = img[..., 0] img[..., 2] = img[..., 0] gray_arr = img[..., 0] # single channel hue_new = nphusl.to_hue(gray_arr) for row in range(gray_arr.shape[0]): for col in range(gray_arr.shape[1]): husl_old = husl.rgb_to_husl(*img[row, col]) assert husl_old[1] < 1 # low saturation # inaccurate hue values at low saturation _diff(hue_new[row, col], husl_old[0], diff=5)
def test_to_hue_3d(): img = _img() # 3D as_husl = nphusl.rgb_to_husl(img / 255.0) just_hue = nphusl.to_hue(img) assert _diff(as_husl[..., 0], just_hue)
def test_to_hue(): img = _img()[0] # 2D as_husl = nphusl.to_husl(img) just_hue = nphusl.to_hue(img) assert _diff(as_husl[..., 0], just_hue)
def test_to_hue_3d(): img = _img() # 3D as_husl = _nphusl._rgb_to_husl(img / 255.0) just_hue = nphusl.to_hue(img) _diff(as_husl[..., 0], just_hue)
def test_to_hue_2d(): img = _img()[:, 14] # 2D RGB as_husl = nphusl.to_husl(img) just_hue = nphusl.to_hue(img) _diff(as_husl[..., 0], just_hue)