Skip to content Skip to sidebar Skip to footer

Image Loses Quality With Cv2.warpperspective

I am working with OpenCV 3.1 and with Python. My problem comes when I try to deskew (fix the tilt of) an image with text. I am using cv2.warpPerspective to make it possible, but t

Solution 1:

The problem is related to the interpolation required by the warping. If you don't want things to appear smoother, you should switch from default interpolation method, which is INTER_LINEAR to another one, such as INTER_NEAREST. It would help you with the sharpness of the edges.

Try flags=cv2.INTER_NEAREST on your warp call, be it warpAffine() or warpPerspective().

Interpolation flags are listed here.

enumInterpolationFlags { 
    INTER_NEAREST = 0, 
    INTER_LINEAR = 1, 
    INTER_CUBIC = 2, 
    INTER_AREA = 3, 
    INTER_LANCZOS4 = 4, 
    INTER_MAX = 7, 
    WARP_FILL_OUTLIERS = 8, 
    WARP_INVERSE_MAP = 16 
}

Post a Comment for "Image Loses Quality With Cv2.warpperspective"