def prediction_to_image(prediction, reshape=False):
""" Converts a prediction map to the RGB image
Args:
prediction (array): the input map to convert
reshape (bool, optional): True if reshape the input from Caffe format
to numpy standard 2D array
Returns:
array: RGB-encoded array
"""
if reshape:
prediction = np.swapaxes(np.swapaxes(prediction, 0, 2), 0, 1)
image = np.zeros(prediction.shape[:2] + (3,), dtype='uint8')
for x in xrange(prediction.shape[0]):
for y in xrange(prediction.shape[1]):
image[x,y] = label_to_pixel(prediction[x,y])
return image
# In[6]:
# Simple sliding window function
评论列表
文章目录