本文整理匯總了Python中skimage.color.rgb2ycbcr方法的典型用法代碼示例。如果您正苦於以下問題:Python color.rgb2ycbcr方法的具體用法?Python color.rgb2ycbcr怎麽用?Python color.rgb2ycbcr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類skimage.color
的用法示例。
在下文中一共展示了color.rgb2ycbcr方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_channel
# 需要導入模塊: from skimage import color [as 別名]
# 或者: from skimage.color import rgb2ycbcr [as 別名]
def set_channel(*args, n_channels=3):
def _set_channel(img):
if img.ndim == 2:
img = np.expand_dims(img, axis=2)
c = img.shape[2]
if n_channels == 1 and c == 3:
img = np.expand_dims(sc.rgb2ycbcr(img)[:, :, 0], 2)
elif n_channels == 3 and c == 1:
img = np.concatenate([img] * n_channels, 2)
return img
return [_set_channel(a) for a in args]
示例2: set_channel
# 需要導入模塊: from skimage import color [as 別名]
# 或者: from skimage.color import rgb2ycbcr [as 別名]
def set_channel(l, n_channel):
def _set_channel(img):
if img.ndim == 2:
img = np.expand_dims(img, axis=2)
c = img.shape[2]
if n_channel == 1 and c == 3:
img = np.expand_dims(sc.rgb2ycbcr(img)[:, :, 0], 2)
elif n_channel == 3 and c == 1:
img = np.concatenate([img] * n_channel, 2)
return img
return [_set_channel(_l) for _l in l]
示例3: set_channel
# 需要導入模塊: from skimage import color [as 別名]
# 或者: from skimage.color import rgb2ycbcr [as 別名]
def set_channel(*args, n_channels=3):
def _set_channel(img):
if img.ndim == 2:
img = np.expand_dims(img, axis=2)
c = img.shape[2]
if n_channels == 1 and c == 3:
img = np.expand_dims(sc.rgb2ycbcr(img)[:, :, 0], 2)
elif n_channels == 3 and c == 1:
img = np.concatenate([img] * n_channels, 2)
return img
return [_set_channel(a) for a in args]
示例4: luminance
# 需要導入模塊: from skimage import color [as 別名]
# 或者: from skimage.color import rgb2ycbcr [as 別名]
def luminance(self, image):
# Get luminance
lum = rgb2ycbcr(image)[:,:,0]
# Crop off 4 border pixels
lum = lum[4:lum.shape[0]-4, 4:lum.shape[1]-4]
#lum = lum.astype(np.float64)
return lum
示例5: eval_psnr_and_ssim
# 需要導入模塊: from skimage import color [as 別名]
# 或者: from skimage.color import rgb2ycbcr [as 別名]
def eval_psnr_and_ssim(im1, im2, scale):
im1_t = np.atleast_3d(img_as_float(im1))
im2_t = np.atleast_3d(img_as_float(im2))
if im1_t.shape[2] == 1 or im2_t.shape[2] == 1:
im1_t = im1_t[..., 0]
im2_t = im2_t[..., 0]
else:
im1_t = rgb2ycbcr(im1_t)[:, :, 0:1] / 255.0
im2_t = rgb2ycbcr(im2_t)[:, :, 0:1] / 255.0
if scale > 1:
im1_t = mod_crop(im1_t, scale)
im2_t = mod_crop(im2_t, scale)
# NOTE conventionally, crop scale+6 pixels (EDSR, VDSR etc)
im1_t = crop_boundaries(im1_t, int(scale) + 6)
im2_t = crop_boundaries(im2_t, int(scale) + 6)
psnr_val = compare_psnr(im1_t, im2_t)
ssim_val = compare_ssim(
im1_t,
im2_t,
win_size=11,
gaussian_weights=True,
multichannel=True,
data_range=1.0,
K1=0.01,
K2=0.03,
sigma=1.5)
return psnr_val, ssim_val