本文整理汇总了Python中skimage.color.lab2lch函数的典型用法代码示例。如果您正苦于以下问题:Python lab2lch函数的具体用法?Python lab2lch怎么用?Python lab2lch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lab2lch函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rgb_lch_roundtrip
def test_rgb_lch_roundtrip(self):
rgb = img_as_float(self.img_rgb)
lab = rgb2lab(rgb)
lch = lab2lch(lab)
lab2 = lch2lab(lch)
rgb2 = lab2rgb(lab2)
assert_array_almost_equal(rgb, rgb2)
示例2: rgb2lch
def rgb2lch(rgb):
"""Convert RBG to LCH colorspace (via LAB)
Input and output are in (bands, cols, rows) order
"""
# reshape for skimage (bands, cols, rows) -> (cols, rows, bands)
srgb = np.swapaxes(rgb, 0, 2)
# convert colorspace
lch = lab2lch(rgb2lab(srgb))
# return in (bands, cols, rows) order
return np.swapaxes(lch, 2, 0)
示例3: test_lab_lch_3d
def test_lab_lch_3d(self):
lab0 = self._get_lab0()
lch0 = lab2lch(lab0)
lch3 = lab2lch(lab0[None, None, None, :])
assert_array_almost_equal(lch0, lch3[0, 0, 0, :])
示例4: test_lab_lch_roundtrip
def test_lab_lch_roundtrip(self):
rgb = img_as_float(self.img_rgb)
lab = rgb2lab(rgb)
lab2 = lch2lab(lab2lch(lab))
assert_array_almost_equal(lab2, lab)
示例5: G
if img.dtype != 'float32':
img = cv2.normalize(img.astype('float32'), None, 0.0, 1.0, cv2.NORM_MINMAX)
# get dimensions of input image
x, y, z = img.shape
# store a copy of original image for comparison
img1 = np.zeros((x, y, z))
img1 = img.copy()
alpha = None
# Convert to colorspaces CIELAB, CIELUV, and CIELCH
lab = color.rgb2lab(img) # - RGB to LAB
luv = color.rgb2luv(img) # - RGB to LUV
LCH = color.lab2lch(img) # - LAB to LCH
# Compute G(x, y) for image
Gx = np.zeros((x, y)) # Create empty array for Gx component
Gy = np.zeros((x, y)) # Create empty array for Gy component
for i in range(1, x-1):
for j in range(1, y-1):
#Calculate the Gx and Gy per pixel using color difference from Eq 3 (on pg 2 of paper)
Gx[i, j] = color_difference(lab[i + 1, j, :], lab[i - 1, j, :], luv[i + 1, j, :], luv[i - 1, j, :], alpha)
Gy[i, j] = color_difference(lab[i, j + 1, :], lab[i, j - 1, :], luv[i, j + 1, :], luv[i, j - 1, :], alpha)
# Assign Lightness, chroma, and hue arrays from LCH to their own respective arrays
L = LCH[:, :, 0]
C = LCH[:, :, 1]
H = LCH[:, :, 2]
T = np.zeros((x, y, 9))