Пример #1
0
def segment_image(im, idx, scene, depth_threshold=0.1, angle_threshold=20, min_points=100):
    floor_idx = [x["idx"] for x in scene if x["model"] == "Floor"][0]
    wall_idx = [x["idx"] for x in scene if x["model"] == "Wall"][0]

    imc = im.copy()
    imc[idx == floor_idx] = 0
    imc[idx == wall_idx] = 0

    points = compute_points(imc)
    normals = compute_normals(points)
    return seg.segment_normals(points, normals, depth_threshold, angle_threshold, min_points)
Пример #2
0
#depth_image = spm.imread('kinect_data/depth.1352980264.888936388.png', True)
idx_image = spm.imread('test_data/3.idx.png')

mask = depth_image == 0
depth_image = cv2.bilateralFilter(depth_image, 9, 30, 100)
depth_image[mask] = 0


pylab.imshow(depth_image)
pylab.show()

points = d.compute_points(depth_image)
normals = d.compute_normals(points)
#normals = seg.compute_normals(points, 0.02, 10)

labels, num_labels = seg.segment_normals(points, normals, 0.1, 10, 100)

#depth_image[labels == 0] = 0
#pylab.imshow(depth_image)
#pylab.show()


max_elements = 4

segments = []
for i in range(num_labels):
	v, u = np.nonzero(labels == i)
	object_idx = np.unique(idx_image[(v, u)])
	if object_idx.shape[0] == 1:
		segments.append({'segmentation_label':i, 'object_label':object_idx[0], 'u':u, 'v':v})