def to_3d_points(im, th=1e-06, downsample=5):
    (xs, ys, ds) = ([], [], [])
    if (len(im.shape) == 4):
        im3d = np.sum(im, axis=3)
    else:
        im3d = im
    (depth, width, height) = im3d.shape
    step_vol = (downsample ** 3)
    for x in range(0, (width - downsample), downsample):
        for y in range(0, (height - downsample), downsample):
            for d in range(0, (depth - downsample), downsample):
                if ((np.sum(im3d[d:(d + downsample), x:(x + downsample), y:(y + downsample)]) / step_vol) > th):
                    xs.append((x + (downsample // 2)))
                    ys.append((y + (downsample // 2)))
                    ds.append((d + (downsample // 2)))
    return (np.array(xs), np.array(ys), np.array(ds))
def to_3d_points(im, th=1e-06, downsample=5):
    (xs, ys, ds) = ([], [], [])
    if (len(im.shape) == 4):
        im3d = np.sum(im, axis=3)
    else:
        im3d = im
    (depth, width, height) = im3d.shape
    step_vol = (downsample ** 3)
    for x in range(0, (width - downsample), downsample):
        for y in range(0, (height - downsample), downsample):
            for d in range(0, (depth - downsample), downsample):
                if ((np.sum(im3d[d:(d + downsample), x:(x + downsample), y:(y + downsample)]) / step_vol) > th):
                    xs.append((x + (downsample // 2)))
                    ys.append((y + (downsample // 2)))
                    ds.append((d + (downsample // 2)))
    return (np.array(xs), np.array(ys), np.array(ds))