Image rotation – which seems trivial – has big implications in computer vision industry. The quality and even more so the speed at which a vision library can perform various types of rotation is vital to some industries. For example the rate at which a scanner can churn pages impacts greatly on its sales. That’s why Scantron, a global leader in scanning, uses CUVI for their line of products to self-align scanned documents at an insanely fast rate.
Image rotation can be of two broad types: cropping and non-cropping. Most image editing software uses cropping-based rotation (along with zoom) for image straighten purposes. Industries and data sensitive application, on the other hand, use non-cropping rotation.
This type retains image dimensions while rotating the image about a point called anchor. Since the dimension of the original image is retained, it crops the image at some parts of the edge (hence the name) and adds blank regions to the other. The amount of crop and blank region depends on the angle of rotation. In cropping rotation, the anchor defines the pivot point for rotation. Most libraries default anchor at the center of the image or at the origin (0,0) of the image. CUVI provides the ability to choose any point of the image to act as an anchor point, the advantage of which I’ll explain later in this article. Moreover CUVI also provides the ability to choose ROI (region of interest) within an image to perform rotation specifically to that region. For usage detail of cropping rotation visit here.
Let’s go through the use-cases of this type of rotate and when it might get handy. The most basic rotate can be cropping rotate with center of the image as anchor. It’s usually followed by a crop or resize and is used to straighten a skew image where you can afford to lose image data at the edges.
If there’s a critical data at one corner of the image, you can select that as the anchor point for rotation and still be able to fix the skew.
The same can be applied to ROI based rotate. And ideal use-case would be an image where you’re only interested in aligning a specific portion of the image.
As the name suggest this type of rotate preserves the data of original image. The catch is that the resultant image has a varying size depending upon the angle of rotation. This type of rotate usually also follows with a cropping function to get the desired results. The anchor point becomes irrelevant in this type of rotate since the original data of image stays preserved. See how to use this type of rotate in code, here.
CUVI over NPP
NPP is considered a library of primitive of primitives. With it, you get to taste the meal but not eat it. Rotate for example is limited to cropping rotate with center as the fixed pivot point. Up till today NPP lacks non-cropping rotate as well as freedom to select the pivot point in the image. Moreover, the edge anti-aliasing is not properly handled by NPP. Check the image below:
An A4 sheet scanned at 300 DPI amounts to 2480 x 3508 pixels which is about 4k image. CUVI is capable of performing self aligning to those scanned sheets at about 1,500 sheets per second which make it anything but a bottleneck in the scanning pipeline.
CUVIlib - CUDA Vision & Imaging Library - is a simple to use, GPU accelerated computer vision SDK. The library is available for download for free for personal unlimited use. For more information, visit our website at cuvilib.com.