LBitmap::AlignImages

Summary

Aligns two images (the pRefBitmap and pTempBitmap) based on the locations of the input points. The images are combined, creating the ppOutBitmap.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::AlignImages(pTempBitmap, ppOutBitmap, RefPoints, TempPoints, PointsCount, nTransformationMethod)

Parameters

BITMAPHANDLE* pTempBitmap

Pointer to a bitmap handle that represents the template bitmap to be mapped to the reference bitmap.

BITMAPHANDLE** ppOutBitmap

Pointer of pointer to a bitmap handle to be updated with the result of the registration.

L_POINT* RefPoints

Pointer to variable that contains the feature points in the reference bitmap to be used for the registration process.

L_POINT* TempPoints

Pointer to variable that contains the feature points in the template bitmap to be used for the registration process.

L_INT PointsCount

Number of registration points.

L_UINT nTransformationMethod

Flag that determines which transformation method to use during registration. Possible values are:

Value Meaning
IMAGE_REGISTRATION_UNKNOWN Unknown transformation type. The transformation algorithm will be selected automatically.
IMAGE_REGISTRATION_XY Performs XY translation using one pair of corresponding points during registration.
IMAGE_REGISTRATION_RSXY Performs rotational, scaling and XY transformations using two pairs of corresponding points during registration.
IMAGE_REGISTRATION_AFFINE6 Performs rotational, scaling, shearing, and XY transformations using three pairs of corresponding points during registration.
IMAGE_REGISTRATION_AFFINE8 Performs perspective transformation using four pairs of corresponding points during registration.

Returns

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

Comments

The pTempBitmap should have the same depth (i.e. Bits Per Pixel) as the class bitmap.

For best results, choose points that are far apart from each other.

The transformation performed depends upon the number of pairs of corresponding points given. As many as four pairs can be given.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images.

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

This function supports signed/unsigned images.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Example

#if defined (LEADTOOLS_V19_OR_LATER) 
L_INT LBitmap__AlignImagesExample(L_VOID) 
{ 
    L_INT nRet; 
    LBitmap LeadBitmap; 
 
    nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("cannon.jpg")), 0,ORDER_BGR); 
    if(nRet !=SUCCESS) 
        return nRet ; 
 
    /* Load and rotate Template image to be registered*/ 
    BITMAPHANDLE TemplateImage ; 
    pBITMAPHANDLE pTemplateImage = &TemplateImage ; 
    nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("cannon.jpg")), pTemplateImage, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
    if(nRet !=SUCCESS) 
        return nRet ; 
 
    nRet = L_RotateBitmap( pTemplateImage, 4500, ROTATE_BICUBIC, 0); 
    if(nRet != SUCCESS) 
    { 
        if(pTemplateImage->Flags.Allocated) 
            L_FreeBitmap(pTemplateImage); 
 
        return nRet ; 
    } 
 
    //Set feature points from the two images that correspond to each other. 
    L_POINT RefPoints[2] ; 
    L_POINT TempPoints[2] ; 
 
    RefPoints[0].x = 173 ; RefPoints[0].y = 102 ; 
    RefPoints[1].x = 216 ; RefPoints[1].y = 259 ; 
 
    TempPoints[0].x = 239 ; TempPoints[0].y = 66  ; 
    TempPoints[1].x = 158 ; TempPoints[1].y = 207 ; 
 
    pBITMAPHANDLE pOutBitmap = NULL ; 
 
    nRet = LeadBitmap.AlignImages( pTemplateImage, 
                                   &pOutBitmap, 
                                   RefPoints, 
                                   TempPoints, 
                                   2, 
                                   IMAGE_REGISTRATION_UNKNOWN ) ; 
 
    //free bitmaps 
    if(pTemplateImage->Flags.Allocated) 
        L_FreeBitmap(pTemplateImage); 
 
    if(pOutBitmap->Flags.Allocated) 
        L_FreeBitmap(pOutBitmap); 
 
    return nRet; 
} 
#endif // LEADTOOLS_V19_OR_LATER 
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++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.