Python cv2.convertMaps() Examples

The following are 2 code examples of cv2.convertMaps(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .
Example #1
Source File: utils.py    From PartiallyReversibleUnet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def dense_image_warp(im, dx, dy, interp=cv2.INTER_LINEAR):

        map_x, map_y = deformation_to_transformation(dx, dy)

        do_optimization = (interp == cv2.INTER_LINEAR)
        # The following command converts the maps to compact fixed point representation
        # this leads to a ~20% increase in speed but could lead to accuracy losses
        # Can be uncommented
        if do_optimization:
            map_x, map_y = cv2.convertMaps(map_x, map_y, dstmap1type=cv2.CV_16SC2)

        remapped = cv2.remap(im, map_x, map_y, interpolation=interp, borderMode=cv2.BORDER_REFLECT) #borderValue=float(np.min(im)))
        if im.ndim > remapped.ndim:
            remapped = np.expand_dims(remapped, im.ndim)
        return remapped 
Example #2
Source File: utils.py    From PHiSeg-code with Apache License 2.0 5 votes vote down vote up
def dense_image_warp(im, dx, dy, interp=cv2.INTER_LINEAR, do_optimisation=True):

        map_x, map_y = deformation_to_transformation(dx, dy)

        # The following command converts the maps to compact fixed point representation
        # this leads to a ~20% increase in speed but could lead to accuracy losses
        # Can be uncommented
        if do_optimisation:
            map_x, map_y = cv2.convertMaps(map_x, map_y, dstmap1type=cv2.CV_16SC2)
        return cv2.remap(im, map_x, map_y, interpolation=interp, borderMode=cv2.BORDER_REFLECT) #borderValue=float(np.min(im)))