L_UnWarp

Summary

Removes the distortion in an image of a cylindrical object, as if removing a label from off of the cylinder and flattening it out.

Syntax

#include "Ltimgcor.h"

L_LTIMGCOR_API L_INT L_UnWarp(pInputBitmap, pOutputBitmap, pPoints, uFlags)

Parameters

pBITMAPHANDLE pInputBitmap

Pointer to the input bitmap handle.

pBITMAPHANDLE pOutputBitmap

Pointer to the output bitmap handle.

L_POINT * pPoints

Pointer to an array of L_POINT structures that represents the locations of the input points on the distorted image.

L_UINT uFlags

Reserved for future use.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Typically, this function is used in preprocessing images from digital cameras. This function requires an array of 8 points. An Invalid Parameters Exception will be thrown if no array of 8 points is passed. The following image shows the use of this function to flatten a label from a pill bottle. The numbers on the label represent the points in the array. The four corners (1, 2, 3, and 4) are fixed points. The interior points on the label (5, 6, 7, and 8) are the ones that are moved to flatten the image.

unwarp.png

Use the L_UnWarp function if the image contains a distortion of a cylindrical object. Use the L_ManualPerspectiveDeskew, L_PerspectiveDeskew / L_PerspectiveDeskewExt, or L_Keystone function if there is a planar deformation along all three axes. Use the L_DeskewBitmap function if there is deformation along both the x- and y- axes.

This function supports 24- and 36-bit color images, 8-bit grayscale images, and 1-bit binarized images.

This function supports signed/unsigned images.

UnWarp Function - Before

UnWarp Function - Before

UnWarp Function - After

UnWarp Function - After

View additional platform support for this UnWarp function.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\LEADTOOLS22\\Resources\\Images\\")pFileName 
 
L_INT UnWarpExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE inputBitmap;    /* Bitmap handle for the initial image */ 
   BITMAPHANDLE OutputBitmap = { 0 }; /* Pointer to bitmap handle for the output image */ 
   L_POINT pPoints[8];          /* Points that define how to unwarp the image */ 
 
   /* Load the input bitmap */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("UnWarp1.JPG")), &inputBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Populate the pPoints list */ 
   L_Point_Make(pPoints + 0, 1205, 852); // Top left 
   L_Point_Make(pPoints + 1, 2176, 853); // Top right 
   L_Point_Make(pPoints + 2, 2128, 1998); // Bottom right 
   L_Point_Make(pPoints + 3, 1217, 1997); // Bottom left 
   L_Point_Make(pPoints + 4, 1528, 853); // Top left third 
   L_Point_Make(pPoints + 5, 1853, 853); // Top right third 
   L_Point_Make(pPoints + 6, 1520, 2159); // Bottom left third 
   L_Point_Make(pPoints + 7, 1825, 2162); // Bottom right third 
 
   /* Perform the unwarp */ 
   nRet = L_UnWarp(&inputBitmap, &OutputBitmap, pPoints, 0); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Save the result */ 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &OutputBitmap, FILE_BMP, 0, 0, NULL); 
 
   /* Free the bitmaps */ 
   L_FreeBitmap(&OutputBitmap); 
   L_FreeBitmap(&inputBitmap); 
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.