L_UnWarp

#include "Ltimgcor.h"

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

pBITMAPHANDLE pInputBitmap;

pointer to a bitmap handle

pBITMAPHANDLE pOutputBitmap;

pointer of a pointer to a bitmap handle

L_POINT pPoints;

pointer to an array of structures

L_UINT uFlags;

 flags

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

Parameter

Description

pInputBitmap

Pointer to the input bitmap handle

pOutputBitmap

Pointer of a pointer to the output bitmap handle

pPoints

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

uFlags

Reserved for future use

Returns

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.

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

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.

Example

#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_FreeBitmap(pOutputBitmap); 
    L_FreeBitmap(&inputBitmap); 
    return SUCCESS; 
} 

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