Exemplo n.º 1
0
def getProbabilityMax(segmentation):
	width = segmentation.shape[2]
	height = segmentation.shape[1]
	numPlanes = segmentation.shape[0]
	inds = np.argmax(segmentation.reshape([-1, height * width]), axis=0)
	probabilities = np.zeros((height * width, numPlanes))
	probabilities[np.arange(height * width), inds] = 1
	probabilities = probabilities.reshape([height, width, -1])
		return probabilities
Exemplo n.º 2
0
def drawSegmentationImage(segmentations,
                          randomColor=None,
                          numColors=22,
                          planeMask=1,
                          offset=1,
                          black=False):
    randomColor = ColorPalette(numColors).getColorMap()
    if black:
        randomColor[0] = 0
        pass
    width = segmentations.shape[1]
    height = segmentations.shape[0]
    if segmentations.ndim == 2:
        segmentation = (segmentations + offset) * planeMask
    else:
        #segmentation = (np.argmax(segmentations, 2) + 1) * (np.max(segmentations, 2) > 0.5)
        if black:
            segmentation = np.argmax(segmentations, 2)
        else:
            segmentation = (np.argmax(segmentations, 2) + 1) * planeMask
            pass
        pass
    segmentation = segmentation.astype(np.int)
    return randomColor[segmentation.reshape(-1)].reshape((height, width, 3))
Exemplo n.º 3
0
			randomColor[0] = 0
				pass
			width = segmentations.shape[1]
			height = segmentations.shape[0]
		if segmentations.ndim == 2:
			segmentation = (segmentations + offset) * planeMask
		else:
			#segmentation = (np.argmax(segmentations, 2) + 1) * (np.max(segmentations, 2) > 0.5)
				if black:
					segmentation = np.argmax(segmentations, 2)
				else:
					segmentation = (np.argmax(segmentations, 2) + 1) * planeMask
						pass
				pass
			segmentation = segmentation.astype(np.int)
		return randomColor[segmentation.reshape(-1)].reshape((height, width, 3))

def drawMaskImage(mask):
		return (mask * 255).astype(np.uint8)

def drawDiffImage(values_1, values_2, threshold):
	#return cv2.applyColorMap(np.clip(np.abs(values_1 - values_2) / threshold * 255, 0, 255).astype(np.uint8), cv2.COLORMAP_JET)
		return np.clip(np.abs(values_1 - values_2) / threshold * 255, 0, 255).astype(np.uint8)


def getSuperpixels(depth, normal, width, height, numPlanes=50, numGlobalPlanes = 10):
	depth = np.expand_dims(depth, -1)

	urange = (np.arange(width, dtype=np.float32) / (width + 1) - 0.5) / focalLength * 641
	urange = np.tile(np.reshape(urange, [1, -1]), [height, 1])
	vrange = (np.arange(height, dtype=np.float32) / (height + 1) - 0.5) / focalLength * 481