Image pixels getting lost while rotation using leptonica

自作多情 提交于 2019-12-13 00:38:57

问题


I want to extract text from an image for which I need to rotate it in steps of 90 degrees.When I rotate the image using

pixRotate(image, deg2rad * angle, L_ROTATE_AREA_MAP, L_BRING_IN_BLACK, 0, 0)

some pixels at the top and bottom are lost.The variations I have tried are

pixRotate(image, deg2rad * angle, L_ROTATE_AREA_MAP, L_BRING_IN_BLACK, w, h)

and also with L_ROTATE_SHEAR, L_ROTATE_SAMPLING.However The pixels near the boundary are getting lost in each case.Is there a way to do this rotation without loosing pixels?


回答1:


You have specific functions for 90°, 180° and 270° rotations, that are defined in rotateorth.c, as detailed in the documentation :

  Top-level rotation by multiples of 90 degrees: PIX *pixRotateOrth()
  180-degree rotation: PIX *pixRotate180()
  90-degree rotation (both directions): PIX *pixRotate90()
  Left-right flip: PIX     *pixFlipLR()
  Top-bottom flip: PIX     *pixFlipTB()

For those rotations (90° or 180°) you should only consider the functions above, since they don't make any approximation of pixel position in the destination image (and they are much faster): so you won't loose any pixels. The pixRotate function (and the ones alike) are for any other angle.



来源:https://stackoverflow.com/questions/24572994/image-pixels-getting-lost-while-rotation-using-leptonica

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!