#include "Ltimgcor.h"
L_LTIMGCOR_API L_INT L_UnWarp(pInputBitmap, ppOutputBitmap, pPoints, uFlags)
Removes the distortion in an image of a cylindrical object, as if removing a label from off of the cylinder and flattening it out.
Pointer to the input bitmap handle
Address of a pointer to the output bitmap handle
Pointer to an array of L_POINT structures that represents the locations of the input points on the distorted image
Reserved for future use
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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.
Use the L_UnWarp function if the image contains a distortion of a cylindrical object. Use the L_ManualPerspectiveDeskew, L_PerspectiveDeskew, 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.
Required DLLs and Libraries
Win32, x64, Linux.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT UnWarpExample (L_VOID)
{
L_INT nRet;
BITMAPHANDLE inputBitmap; /* Bitmap handle for the initial image */
pBITMAPHANDLE pOutputBitmap; /* 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, &pOutputBitmap, pPoints, 0);
if(nRet != SUCCESS)
return nRet;
/* Save the result */
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), pOutputBitmap, FILE_BMP, 0, 0, NULL);
/* Free the bitmaps */
L_FreeUnWarpBitmap(pOutputBitmap);
L_FreeBitmap(&inputBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document