当前位置: 首页>>代码示例>>Python>>正文


Python color.hsv2rgb方法代码示例

本文整理汇总了Python中skimage.color.hsv2rgb方法的典型用法代码示例。如果您正苦于以下问题:Python color.hsv2rgb方法的具体用法?Python color.hsv2rgb怎么用?Python color.hsv2rgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage.color的用法示例。


在下文中一共展示了color.hsv2rgb方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _apply_

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def _apply_(self, *image):
        res = ()
        n_img = 0
        for img in image:
            if n_img == 0:
                #pdb.set_trace()
                ### transform image into HSV
                img = img_as_ubyte(color.rgb2hsv(img))
                ### perturbe each channel H, E, Dab
                for i in range(3):
                    k_i = self.params['k'][i] 
                    b_i = self.params['b'][i] 
                    img[:,:,i] = GreyValuePerturbation(img[:, :, i], k_i, b_i, MIN=0., MAX=255)
                    #plt.imshow(img[:,:,i], "gray")
                    #plt.show()
                sub_res = img_as_ubyte(color.hsv2rgb(img))
            else:
                sub_res = img

            res += (sub_res,)
            n_img += 1
        return res 
开发者ID:PeterJackNaylor,项目名称:DRFNS,代码行数:24,代码来源:ImageTransform.py

示例2: get_masked_image

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def get_masked_image(img, mask, multiplier=0.6):
  """
  :param img: The image to be masked.
  :param mask: Binary mask to be applied. The object should be represented by 1 and the background by 0
  :param multiplier: Floating point multiplier that decides the colour of the mask.
  :return: Masked image
  """
  img_mask = np.zeros_like(img)
  indices = np.where(mask == 1)
  img_mask[indices[0], indices[1], 1] = 1
  img_mask_hsv = color.rgb2hsv(img_mask)
  img_hsv = color.rgb2hsv(img)
  img_hsv[indices[0], indices[1], 0] = img_mask_hsv[indices[0], indices[1], 0]
  img_hsv[indices[0], indices[1], 1] = img_mask_hsv[indices[0], indices[1], 1] * multiplier

  return color.hsv2rgb(img_hsv) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:18,代码来源:Util.py

示例3: create_image

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def create_image(model, x, y, r, z):
    '''
    create an image for the given latent vector z 
    '''
    # create input vector
    Z = np.repeat(z, x.shape[0]).reshape((-1,x.shape[0]))
    X = np.concatenate([x, y, r, Z.T], axis=1)

    pred = model.predict(X)
    
    img = []
    for k in range(pred.shape[1]):
        yp = pred[:, k]
#        if k == pred.shape[1]-1:
#            yp = np.sin(yp)
        yp = (yp - yp.min()) / (yp.max()-yp.min())
        img.append(yp.reshape(y_dim, x_dim))
        
    img = np.dstack(img)
    if img.shape[-1] == 3:
        from skimage.color import hsv2rgb
        img = hsv2rgb(img)
        
    return (img*255).astype(np.uint8) 
开发者ID:hochthom,项目名称:cppn-keras,代码行数:26,代码来源:cppn.py

示例4: masked

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def masked(img, gt, mask, alpha=1):
    """Returns image with GT lung field outlined with red, predicted lung field
    filled with blue."""
    rows, cols = img.shape[:2]
    color_mask = np.zeros((rows, cols, 3))
    boundary = morphology.dilation(gt, morphology.disk(3)) ^ gt
    color_mask[mask == 1] = [0, 0, 1]
    color_mask[boundary == 1] = [1, 0, 0]
    
    img_hsv = color.rgb2hsv(img)
    color_mask_hsv = color.rgb2hsv(color_mask)

    img_hsv[..., 0] = color_mask_hsv[..., 0]
    img_hsv[..., 1] = color_mask_hsv[..., 1] * alpha

    img_masked = color.hsv2rgb(img_hsv)
    return img_masked 
开发者ID:SConsul,项目名称:Global_Convolutional_Network,代码行数:19,代码来源:inferences.py

示例5: RDMcolormap

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def RDMcolormap(nCols=256):

    # blue-cyan-gray-red-yellow with increasing V (BCGRYincV)
    anchorCols = np.array([
        [0, 0, 1],
        [0, 1, 1],
        [.5, .5, .5],
        [1, 0, 0],
        [1, 1, 0],
    ])

    # skimage rgb2hsv is intended for 3d images (RGB)
    # here we add a new axis to our 2d anchorCols to satisfy skimage, and then squeeze
    anchorCols_hsv = rgb2hsv(anchorCols[np.newaxis, :]).squeeze()

    incVweight = 1
    anchorCols_hsv[:, 2] = (1-incVweight)*anchorCols_hsv[:, 2] + \
        incVweight*np.linspace(0.5, 1, anchorCols.shape[0]).T

    # anchorCols = brightness(anchorCols)
    anchorCols = hsv2rgb(anchorCols_hsv[np.newaxis, :]).squeeze()

    cols = colorScale(nCols, anchorCols)

    return ListedColormap(cols) 
开发者ID:Charestlab,项目名称:pyrsa,代码行数:27,代码来源:RDMcolormap.py

示例6: get_masked_image

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def get_masked_image(img, mask, multiplier=0.6):
  """
  :param img: The image to be masked.
  :param mask: Binary mask to be applied. The object should be represented by 1 and the background by 0
  :param multiplier: Floating point multiplier that decides the colour of the mask.
  :return: Masked image
  """
  img_mask = np.zeros_like(img)
  indices = np.where(mask == 1)
  img_mask[indices[0], indices[1], 1] = 1
  img_mask_hsv = color.rgb2hsv(img_mask)
  img_hsv = color.rgb2hsv(img)
  img_hsv[indices[0], indices[1], 0] = img_mask_hsv[indices[0], indices[1], 0]
  img_hsv[indices[0], indices[1], 1] = img_mask_hsv[indices[0], indices[1], 1] * multiplier

  return color.hsv2rgb(img_hsv)


# Visualize spatial offset in HSV color space as rotation to spatial center (H),
# distance to spatial center (V) 
开发者ID:VisualComputingInstitute,项目名称:TrackR-CNN,代码行数:22,代码来源:Util.py

示例7: masked

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def masked(img, gt, mask, alpha=1):
    """Returns image with GT lung field outlined with red, predicted lung field
    filled with blue."""
    rows, cols = img.shape
    color_mask = np.zeros((rows, cols, 3))
    boundary = morphology.dilation(gt, morphology.disk(3)) - gt
    color_mask[mask == 1] = [0, 0, 1]
    color_mask[boundary == 1] = [1, 0, 0]
    img_color = np.dstack((img, img, img))

    img_hsv = color.rgb2hsv(img_color)
    color_mask_hsv = color.rgb2hsv(color_mask)

    img_hsv[..., 0] = color_mask_hsv[..., 0]
    img_hsv[..., 1] = color_mask_hsv[..., 1] * alpha

    img_masked = color.hsv2rgb(img_hsv)
    return img_masked 
开发者ID:imlab-uiip,项目名称:lung-segmentation-2d,代码行数:20,代码来源:demo.py

示例8: __call__

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def __call__(self, img):
        """numpy array [b, [-1~1], [-1~1], [-1~1]] to target space / result rgb[0~255]"""
        img = img.data.numpy()

        if self.color_space == 'rgb':
            img = (img + 1) * 0.5

        img = img.transpose(0, 2, 3, 1)
        if self.color_space == 'lab': # to [0~100, -128~127, -128~127]
            img[:,:,:,0] = (img[:,:,:,0] + 1) * 50
            img[:,:,:,1] = (img[:,:,:,1] * 127.5) - 0.5
            img[:,:,:,2] = (img[:,:,:,2] * 127.5) - 0.5
            img_list = []
            for i in img:
                img_list.append(color.lab2rgb(i))
            img = np.array(img_list)
        elif self.color_space == 'hsv': # to [0~1, 0~1, 0~1]
            img = (img + 1) * 0.5
            img_list = []
            for i in img:
                img_list.append(color.hsv2rgb(i))
            img = np.array(img_list)

        img = (img * 255).astype(np.uint8)
        return img # [0~255] / [b, h, w, 3] 
开发者ID:blandocs,项目名称:Tag2Pix,代码行数:27,代码来源:dataloader.py

示例9: get_overlayed_image

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def get_overlayed_image(x, c, gray_factor_bg = 0.3):    
    '''
    For an image x and a relevance vector c, overlay the image with the 
    relevance vector to visualise the influence of the image pixels.
    '''
    imDim = x.shape[0]
    
    if np.ndim(c)==1:
        c = c.reshape((imDim,imDim))
    if np.ndim(x)==2: # this happens with the MNIST Data
        x = 1-np.dstack((x, x, x))*gray_factor_bg # make it a bit grayish
    if np.ndim(x)==3: # this is what happens with cifar data        
        x = color.rgb2gray(x)
        x = 1-(1-x)*0.5
        x = np.dstack((x,x,x))
        
    alpha = 0.8
    
    # Construct a colour image to superimpose
    im = plt.imshow(c, cmap = cm.seismic, vmin=-np.max(np.abs(c)), vmax=np.max(np.abs(c)), interpolation='nearest')
    color_mask = im.to_rgba(c)[:,:,[0,1,2]]
    
    # Convert the input image and color mask to Hue Saturation Value (HSV) colorspace
    img_hsv = color.rgb2hsv(x)
    color_mask_hsv = color.rgb2hsv(color_mask)
    
    # Replace the hue and saturation of the original image
    # with that of the color mask
    img_hsv[..., 0] = color_mask_hsv[..., 0]
    img_hsv[..., 1] = color_mask_hsv[..., 1] * alpha
    
    img_masked = color.hsv2rgb(img_hsv)
    
    return img_masked 
开发者ID:lmzintgraf,项目名称:DeepVis-PredDiff,代码行数:36,代码来源:utils_visualise.py

示例10: brightness

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def brightness(_x, c=0.):
    _x = np.array(_x, copy=True) / 255.
    _x = skcolor.rgb2hsv(_x)
    _x[:, :, 2] = np.clip(_x[:, :, 2] + c, 0, 1)
    _x = skcolor.hsv2rgb(_x)

    return np.uint8(_x * 255) 
开发者ID:hendrycks,项目名称:robustness,代码行数:9,代码来源:make_tinyimagenet_p.py

示例11: original_colors

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def original_colors(original, stylized,original_color):
    # Histogram normalization in v channel
    ratio=1. - original_color 

    hsv = color.rgb2hsv(original/255)
    hsv_s = color.rgb2hsv(stylized/255)

    hsv_s[:,:,2] = (ratio* hsv_s[:,:,2]) + (1-ratio)*hsv [:,:,2]
    img = color.hsv2rgb(hsv_s)    
    return img 
开发者ID:misgod,项目名称:fast-neural-style-keras,代码行数:12,代码来源:transform.py

示例12: TF_shift_hue

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def TF_shift_hue(x, shift=0.0):
    assert len(x.shape) == 3
    h, w, nc = x.shape

    hsv = rgb2hsv(x)
    hsv[:,:,0] += shift
    return hsv2rgb(hsv) 
开发者ID:HazyResearch,项目名称:tanda,代码行数:9,代码来源:image_tfs.py

示例13: color_augment_image

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def color_augment_image(data):
    image = data.transpose(1, 2, 0)
    hsv = color.rgb2hsv(image)

    # Contrast 2
    s_factor1 = numpy.random.uniform(0.25, 4)
    s_factor2 = numpy.random.uniform(0.7, 1.4)
    s_factor3 = numpy.random.uniform(-0.1, 0.1)

    hsv[:, :, 1] = (hsv[:, :, 1] ** s_factor1) * s_factor2 + s_factor3

    v_factor1 = numpy.random.uniform(0.25, 4)
    v_factor2 = numpy.random.uniform(0.7, 1.4)
    v_factor3 = numpy.random.uniform(-0.1, 0.1)

    hsv[:, :, 2] = (hsv[:, :, 2] ** v_factor1) * v_factor2 + v_factor3

    # Color
    h_factor = numpy.random.uniform(-0.1, 0.1)
    hsv[:, :, 0] = hsv[:, :, 0] + h_factor

    hsv[hsv < 0] = 0.0
    hsv[hsv > 1] = 1.0

    rgb = color.hsv2rgb(hsv)

    data_out = rgb.transpose(2, 0, 1)
    return data_out 
开发者ID:ifp-uiuc,项目名称:anna,代码行数:30,代码来源:__init__.py

示例14: get_masked_image_hsv

# 需要导入模块: from skimage import color [as 别名]
# 或者: from skimage.color import hsv2rgb [as 别名]
def get_masked_image_hsv(img_hsv, mask, multiplier=0.6):
  """
  :param img_hsv: The hsv image to be masked.
  :param mask: Binary mask to be applied. The object should be represented by 1 and the background by 0
  :param multiplier: Floating point multiplier that decides the colour of the mask.
  :return: Masked image
  """
  img_mask_hsv = np.zeros_like(img_hsv)
  result_image = np.copy(img_hsv)
  indices = np.where(mask == 1)
  img_mask_hsv[indices[0], indices[1], :] = [0.33333333333333331, 1.0, 0.0039215686274509803]
  result_image[indices[0], indices[1], 0] = img_mask_hsv[indices[0], indices[1], 0]
  result_image[indices[0], indices[1], 1] = img_mask_hsv[indices[0], indices[1], 1] * multiplier

  return color.hsv2rgb(result_image) 
开发者ID:JonathonLuiten,项目名称:PReMVOS,代码行数:17,代码来源:Util.py


注:本文中的skimage.color.hsv2rgb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。