本文整理汇总了Python中skimage.io.show方法的典型用法代码示例。如果您正苦于以下问题:Python io.show方法的具体用法?Python io.show怎么用?Python io.show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skimage.io
的用法示例。
在下文中一共展示了io.show方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sport_clip
# 需要导入模块: from skimage import io [as 别名]
# 或者: from skimage.io import show [as 别名]
def get_sport_clip(clip_name, verbose=True):
"""
Loads a clip to be fed to C3D for classification.
TODO: should I remove mean here?
Parameters
----------
clip_name: str
the name of the clip (subfolder in 'data').
verbose: bool
if True, shows the unrolled clip (default is True).
Returns
-------
Tensor
a pytorch batch (n, ch, fr, h, w).
"""
clip = sorted(glob(join('data', clip_name, '*.png')))
clip = np.array([resize(io.imread(frame), output_shape=(112, 200), preserve_range=True) for frame in clip])
clip = clip[:, :, 44:44+112, :] # crop centrally
if verbose:
clip_img = np.reshape(clip.transpose(1, 0, 2, 3), (112, 16 * 112, 3))
io.imshow(clip_img.astype(np.uint8))
io.show()
clip = clip.transpose(3, 0, 1, 2) # ch, fr, h, w
clip = np.expand_dims(clip, axis=0) # batch axis
clip = np.float32(clip)
return torch.from_numpy(clip)
示例2: main
# 需要导入模块: from skimage import io [as 别名]
# 或者: from skimage.io import show [as 别名]
def main():
img = misc.imread("wheat.png")
# labels1 = segmentation.slic(img, compactness=100, n_segments=9)
labels1 = segmentation.slic(img, compactness=50, n_segments=4)
out1 = color.label2rgb(labels1, img, kind='overlay')
print(labels1.shape)
g = graph.rag_mean_color(img, labels1)
labels2 = graph.cut_threshold(labels1, g, 29)
out2 = color.label2rgb(labels2, img, kind='overlay')
# get roi
# logicalIndex = (labels2 != 1)
# gray = rgb2gray(img);
# gray[logicalIndex] = 0;
plt.figure()
io.imshow(out1)
plt.figure()
io.imshow(out2)
io.show()
示例3: spectral_cluster
# 需要导入模块: from skimage import io [as 别名]
# 或者: from skimage.io import show [as 别名]
def spectral_cluster(filename, compactness_val=30, n=6):
img = misc.imread(filename)
labels1 = segmentation.slic(img, compactness=compactness_val, n_segments=n)
out1 = color.label2rgb(labels1, img, kind='overlay', colors=['red','green','blue','cyan','magenta','yellow'])
fig, ax = plt.subplots()
ax.imshow(out1, interpolation='nearest')
ax.set_title("Compactness: {} | Segments: {}".format(compactness_val, n))
plt.show()
示例4: draw_points_on_img
# 需要导入模块: from skimage import io [as 别名]
# 或者: from skimage.io import show [as 别名]
def draw_points_on_img(img, point_ver, point_hor, point_class):
for i in range(len(point_class)):
if point_class[i] != 3:
rr, cc = draw.circle(point_ver[i], point_hor[i], 10, (256, 192))
#draw.set_color(img, [rr, cc], [0., 0., 0.], alpha=5)
img[rr, cc, :] = 0
#io.imshow(img)
#io.show()
return img
示例5: mytest
# 需要导入模块: from skimage import io [as 别名]
# 或者: from skimage.io import show [as 别名]
def mytest():
tfrecord_file = '../dataset/train.tfrecords'
filename_queue = tf.train.string_input_producer([tfrecord_file], num_epochs=None)
image_name, image, keypoints_ver, keypoints_hor, keypoints_class = decode_tfrecord(filename_queue)
with tf.Session() as sess:
init_op = tf.global_variables_initializer()
sess.run(init_op)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
try:
# while not coord.should_stop():
for i in range(10):
img_name, img, point_ver, point_hor, point_class = sess.run([image_name, image, keypoints_ver,
keypoints_hor, keypoints_class])
print(img_name, point_hor, point_ver, point_class)
for i in range(len(point_class)):
if point_class[i] > 0:
rr, cc = draw.circle(point_ver[i], point_hor[i], 10, (256, 192))
img[rr, cc, :] = 0
io.imshow(img)
io.show()
except tf.errors.OutOfRangeError:
print('Done reading')
finally:
coord.request_stop()