L_ManualPerspectiveDeskew

#include "ltimgcor.h"

L_LTIMGCOR_API L_INT L_ManualPerspectiveDeskew(pBitmap, InPoints, ppOutBitmap)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

pMANUALPERSPECTIVEDESKEWPOINTS InPoints;

pointer to a Manual3DDeskewPoints structure

pBITMAPHANDLE* ppOutBitmap;

pointer of a pointer to the bitmap handle that contains the deskewed image.

Corrects the view perspective.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to be transformed.

InPoints

Pointer to ManualPerspectiveDeskewPoints structure that contains a list of points that will be transformed to match the location of the mapped points list

ppOutBitmap

Pointer of pointer to bitmap handle that contains the deskewed image.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The L_ManualPerspectiveDeskew can change the specified image. To keep the original image unchanged, use this function on a copy.

Typically, this function is used as a step when preprocessing images from digital cameras. It changes the image based on a view perspective equation, taking the depth of the objects into account as well as their relative dimensions.

It is best to choose input points that are far away from each other.

Use the **L_ManualPerspectiveDeskew, **L_Keystone, or L_PerspectiveDeskew function if there is a planar deformation along all three axes. Use the L_UnWarp function if there is a cylindrical deformation. Use the L_DeskewBitmap function if there is deformation along both the x- and y- axes.

This function can only process entire images. It does not support regions.

This function supports 24- and 36-bit color images and 8- and 16-bit grayscale images.

This command supports signed/unsigned 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.

Platforms

Win32, x64, Linux.

See Also
Functions: L_PerspectiveDeskew, L_AlignImages, L_Keystone
Topics: Raster Image Functions: Filtering Images
Raster Image Functions: Processing an Image
Raster Image Functions: Doing Geometric Transformations
Removing Noise
Deskewing

Example

This example loads a bitmap and applies manual perspective deskew filter.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT ManualPerspectiveDeskewFilterBitmapExample(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("cannon.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   int Width = LeadBitmap.Width ; 
   int Height = LeadBitmap.Height ; 
   /* Apply manual perspective deskew filter to move down the top right corner by half of the image height*/ 
   MANUALPERSPECTIVEDESKEWPOINTS manual3ddeskewpoints ; 
   manual3ddeskewpoints.InputPoints[0].x = 0        ; manual3ddeskewpoints.InputPoints[0].y   =  0 ; 
   manual3ddeskewpoints.InputPoints[1].x = Width-1  ; manual3ddeskewpoints.InputPoints[1].y   =  0 ; 
   manual3ddeskewpoints.InputPoints[2].x = 0        ; manual3ddeskewpoints.InputPoints[2].y   =  Height-1 ; 
   manual3ddeskewpoints.InputPoints[3].x = Width-1  ; manual3ddeskewpoints.InputPoints[3].y   =  Height-1 ; 
   manual3ddeskewpoints.MappingPoints[0].x = 0        ; manual3ddeskewpoints.MappingPoints[0].y =  0 ; 
   manual3ddeskewpoints.MappingPoints[1].x = Width-1  ; manual3ddeskewpoints.MappingPoints[1].y =  Height/2 ; 
   manual3ddeskewpoints.MappingPoints[2].x = 0        ; manual3ddeskewpoints.MappingPoints[2].y =  Height-1 ; 
   manual3ddeskewpoints.MappingPoints[3].x = Width-1  ; manual3ddeskewpoints.MappingPoints[3].y =  Height-1 ; 
   pBITMAPHANDLE pOutBitmap = NULL; 
   nRet = L_ManualPerspectiveDeskew(&LeadBitmap, &manual3ddeskewpoints, &pOutBitmap); 
   if(nRet !=SUCCESS) 
   { 
      //free bitmap 
      if(LeadBitmap.Flags.Allocated) 
         L_FreeBitmap(&LeadBitmap); 
      return nRet; 
   } 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), pOutBitmap, FILE_BMP, 24, 0, NULL); 
   L_FreeManualPerspectiveDeskewBitmap(pOutBitmap); 
   //free bitmap 
   if(LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
   return nRet; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help