本文整理汇总了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
# -----------------------------------------------------------------------------
示例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.')
示例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)
示例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
示例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
示例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)
示例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____________________________________
#