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


Python skimage.color方法代码示例

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


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

示例1: get_label_colortable

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def get_label_colortable(n_labels, shape):
    if cv2 is None:
        raise RuntimeError('get_label_colortable requires OpenCV (cv2)')
    rows, cols = shape
    if rows * cols < n_labels:
        raise ValueError
    cmap = label_colormap(n_labels)
    table = np.zeros((rows * cols, 50, 50, 3), dtype=np.uint8)
    for lbl_id, color in enumerate(cmap):
        color_uint8 = (color * 255).astype(np.uint8)
        table[lbl_id, :, :] = color_uint8
        text = '{:<2}'.format(lbl_id)
        cv2.putText(table[lbl_id], text, (5, 35),
                    cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), 3)
    table = table.reshape(rows, cols, 50, 50, 3)
    table = table.transpose(0, 2, 1, 3, 4)
    table = table.reshape(rows * 50, cols * 50, 3)
    return table


# -----------------------------------------------------------------------------
# Evaluation
# ----------------------------------------------------------------------------- 
开发者ID:wkentaro,项目名称:fcn,代码行数:25,代码来源:utils.py

示例2: check_duplicated_color

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def check_duplicated_color(text):
    SENTENCE_SPLIT_REGEX = re.compile(r'(\W+)')
    words = SENTENCE_SPLIT_REGEX.split(text.strip())
    words = [w.lower() for w in words if len(w.strip()) > 0]

    sky_color = ''
    ground_color = ''
    for word in words:
        if word in ALL_COLOR:
            if sky_color == '':
                sky_color = word
            else:
                ground_color = word
                break

    if sky_color == ground_color:
        raise Exception('It is not recommended to use the same sky and ground color.') 
开发者ID:SketchyScene,项目名称:SketchySceneColorization,代码行数:19,代码来源:bg_utils.py

示例3: load_image

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def load_image(self, image_index):
        path = self.image_path(image_index)
        img = skimage.io.imread(path)

        if len(img.shape) == 1:
            img = img[0]

        if len(img.shape) == 2:
            img = skimage.color.gray2rgb(img)

        try:
            return img.astype(np.float32) / 255.0
        except Exception:
            print (path)
            exit(0) 
开发者ID:tristandb,项目名称:EfficientDet-PyTorch,代码行数:17,代码来源:oid_dataset.py

示例4: load_image

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def load_image(self, image_index):
        image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
        path       = os.path.join(self.root_dir, 'images', self.set_name, image_info['file_name'])
        img = skimage.io.imread(path)

        if len(img.shape) == 2:
            img = skimage.color.gray2rgb(img)

        return img.astype(np.float32)/255.0 
开发者ID:tristandb,项目名称:EfficientDet-PyTorch,代码行数:11,代码来源:dataloader.py

示例5: preprocess

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def preprocess(self, image, imagesize):
        image = skimage.color.rgb2gray(image)
        image = skimage.transform.resize(image, imagesize, mode='constant')
        image = skimage.exposure.rescale_intensity(image, out_range=(0, 255))
        image = image / 255.0
        return image 
开发者ID:CharlesPikachu,项目名称:AIGames,代码行数:8,代码来源:agent.py

示例6: plotRect

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def plotRect(img,color,xyrhw,lineW=1):
    tl,tr,br,bl = getCorners(xyrhw)

    cv2.line(img,tl,tr,color,lineW)
    cv2.line(img,tr,br,color,lineW)
    cv2.line(img,br,bl,color,lineW)
    cv2.line(img,bl,tl,color,lineW) 
开发者ID:herobd,项目名称:Visual-Template-Free-Form-Parsing,代码行数:9,代码来源:formsboxdetect_printer.py

示例7: collapse_RGB

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import color [as 别名]
def collapse_RGB(self, image, name):
    if len(image.shape) == 3:
      if image.shape[2] == 1:
        #print "  this image (%s)\n   is only one channel as of reaching process_image" % name
        pass
      elif image.shape[2] == 3:
        #image = image.astype('uint8')
        #img_show = PIL.Image.fromarray(image[...,0])
        #img_show.save('./mastcam_images/%s_bandR.png' % name)
        #img_show = PIL.Image.fromarray(image[...,1])
        #img_show.save('./mastcam_images/%s_bandG.png' % name)
        #img_show = PIL.Image.fromarray(image[...,2])
        #img_show.save('./mastcam_images/%s_bandB.png' % name)
        image = image.astype('uint16')
        image = image[...,0] + image[...,1] + image[...,2]
        image = image / 3
        image = image.astype('uint8')
        #img_show = PIL.Image.fromarray(image)
        #img_show.save('./mastcam_images/%s_rgb.png' % name)
      elif image.shape[2] == 7:
        image = image.astype('uint16')
        image = image[...,0] + image[...,1] + image[...,2] + image[...,3] + image[...,4] + image[...,5] + image[...,6]
        image = image / 7
        image = image.astype('uint8')
      else:
        print "This image has %d color bands and that's weird." % image.shape[2]
        exit()
    elif len(image.shape) == 2:
      print "This image has only one channel!"
      pass
    else:
      print "This image has %d dimensions and that's weird." % len(image.shape)
      exit()
      
    return image

#_______________________________________________________________________________
#_______________________________________main____________________________________
# 
开发者ID:wkiri,项目名称:DEMUD,代码行数:41,代码来源:dataset_mastcam.py


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