Ejemplo n.º 1
0
def applyHomographyFast(source, out, H, weights, weightIm, abrupt=False):
    # takes the image source, warps it by the homography H, and adds it to the composite out.
    # This version should only iterate over the pixels inside the bounding box of source's image in out.
    bbox = a6.computeTransformedBBox(source.shape, H)
    Hinv = linalg.inv(H)
    for y in xrange(bbox[0][0], bbox[1][0]):
        for x in xrange(bbox[0][1], bbox[1][1]):
            yp, xp, w = Hinv.dot(np.array([y, x, 1.0]))
            yp, xp = (yp / w, xp / w)
            if yp >= 0 and yp < source.shape[0] and xp >= 0 and xp < source.shape[1]:
                if abrupt and weights[yp, xp, 0] > weightIm[y, x, 0]:
                    weightIm[y, x] = weights[yp, xp]
                    out[y, x] = weights[yp, xp] * a6.interpolateLin(source, yp, xp)
                elif not abrupt:
                    weightIm[y, x] += weights[yp, xp]
                    out[y, x] += weights[yp, xp] * a6.interpolateLin(source, yp, xp)
Ejemplo n.º 2
0
def applyHomographyFast_blended(source, out, H, out_weight, weight_map, onlyHighestWeight=False):
    """Takes the image source, warps it by the homography H, and adds it to the composite out.
    This version should only iterate over the pixels inside the bounding box of source's image in out. """

    bbox = a6.computeTransformedBBox(np.shape(source), H)
    for y in xrange(bbox[0][0], bbox[1][0]):
        for x in xrange(bbox[0][1], bbox[1][1]):
            (yp, xp, wp) = np.dot(linalg.inv(H), np.array([y, x, 1]))
            (ypp, xpp) = (yp / wp, xp / wp)
            if a6.within_bounds(source, ypp, xpp):
                if not onlyHighestWeight:
                    out[y, x] += a6.interpolateLin(source, ypp, xpp) * weight_map[ypp, xpp]
                    out_weight[y, x] += weight_map[ypp, xpp]
                elif np.sum(weight_map[ypp, xpp]) > np.sum(out_weight[y, x]):
                    out[y, x] = a6.interpolateLin(source, ypp, xpp) * weight_map[ypp, xpp]
                    out_weight[y, x] = weight_map[ypp, xpp]
                else:
                    pass
Ejemplo n.º 3
0
def applyHomographyFast(source, out, H, weights, weightIm, abrupt=False):
    # takes the image source, warps it by the homography H, and adds it to the composite out.
    # This version should only iterate over the pixels inside the bounding box of source's image in out.
    bbox = a6.computeTransformedBBox(source.shape, H)
    Hinv = linalg.inv(H)
    for y in xrange(bbox[0][0], bbox[1][0]):
        for x in xrange(bbox[0][1], bbox[1][1]):
            yp, xp, w = Hinv.dot(np.array([y, x, 1.0]))
            yp, xp = (yp / w, xp / w)
            if yp >= 0 and yp < source.shape[
                    0] and xp >= 0 and xp < source.shape[1]:
                if abrupt and weights[yp, xp, 0] > weightIm[y, x, 0]:
                    weightIm[y, x] = weights[yp, xp]
                    out[y, x] = weights[yp, xp] * a6.interpolateLin(
                        source, yp, xp)
                elif not abrupt:
                    weightIm[y, x] += weights[yp, xp]
                    out[y, x] += weights[yp, xp] * a6.interpolateLin(
                        source, yp, xp)