Image loses quality with cv2.warpPerspective

前端 未结 1 1880
执念已碎
执念已碎 2021-01-12 06:50

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

相关标签:
1条回答
  • 2021-01-12 07:20

    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.

    enum InterpolationFlags { 
        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 
    }
    
    0 讨论(0)
提交回复
热议问题