#include "Ltimgcor.h"
L_LTIMGCOR_API L_INT L_Keystone(pBitmap, pPoints, pOutBitmap)
pBITMAPHANDLE pBitmap; |
pointer to the bitmap handle |
L_POINT* pPoints; |
pointer to an L_POINT that contains the four polygon points to be mapped as a rectangle |
pBITMAPHANDLE pOutBitmap; |
pointer of a pointer to the bitmap handle that represents the resulting rectified bitmap |
Performs inverse perspective transformation (keystoning) on an image.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle to be rectified. |
pPoints |
Pointer to an L_POINT that contains the four polygon points on the bitmap that will be mapped to a rectangle. |
pOutBitmap |
Pointer of a pointer to the bitmap handle that represents the resulting rectified bitmap. |
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Frequently, images captured by portable devices are distorted because they are projected onto a surface at an angle. Vertical lines become slanted, etc. The L_Keystone function maps a polygon to a rectangle (an inverse perspective transformation), and can be used to correct the perspective of such images.
Use the L_Keystone or L_ManualPerspectiveDeskew function if there is planar deformation along all three axes. Use the L_UnWarp function if there is a cylindrical deformation.
The input pPoints should contain 4 polygon points. These points will become the corners of the rectangle and the rest of the pixels are shifted accordingly.
This function can only process entire images. It does not support regions.
This function supports 12- and 16-bit grayscale and 48- and 64-bit color images.
Required DLLs and Libraries
LTIMGCOR
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64, Linux.
Functions: | L_PerspectiveDeskew, L_AlignImages |
Topics: | Raster Image Functions: Doing Geometric Transformations |
Processing an Image | |
Deskewing |
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT KeystoneExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("Master.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/* Apply a Keystone filter */
BITMAPHANDLE OutBitmap;
L_POINT pPoints[4] ;
pPoints[0].x = 94 ;
pPoints[0].y = 94 ;
pPoints[1].x = 306 ;
pPoints[1].y = 43 ;
pPoints[2].x = 318 ;
pPoints[2].y = 237 ;
pPoints[3].x = 98 ;
pPoints[3].y = 237 ;
nRet = L_Keystone(&LeadBitmap, pPoints, &OutBitmap);
if (nRet == SUCCESS)
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &OutBitmap, FILE_BMP, 24, 0, NULL);
//free bitmap
if(LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
if(OutBitmap.Flags.Allocated)
L_FreeBitmap(&OutBitmap);
return nRet;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET