LBitmap::GetTransformationParameters

Summary

Computes the rotation angle, XY scaling, and XY translation of the transformed bitmap with comparison to the reference bitmap. These are the transformations that would have to be performed to the reference bitmap to have it match the current bitmap.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::GetTransformationParameters (pRefPoints, pTrnsPoints, pnXTranslation, pnYTranslation,pnAngle, puXScale, puYScale, uFlags = 0)

Parameters

POINT * pRefPoints

Pointer to an array of reference points. These points represent the center of mass points for the registration in the reference bitmap. You have to provide this information.

POINT * pTrnsPoints

Pointer to an array of transformed points. These points are the center of mass points in pBitmap. You have to provide this information.

L_INT * pnXTranslation

Pointer to a variable to be updated by the bitmap x-translation, in hundredths of pixels.

L_INT * pnYTranslation

Pointer to a variable to be updated by the bitmap y-translation, in hundredths of pixels.

L_INT * pnAngle

Pointer to a variable to be updated with the bitmap rotation angle, in hundredths of degrees.

L_UINT * puXScale

Pointer to a variable to be updated with the bitmap x-scaling (resizing), in percent.

L_UINT * puYScale

Pointer to a variable to be updated with the bitmap y-scaling (resizing), in percent.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

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

Comments

This function detects transformation parameters of the transformed bitmap by comparing it with the reference bitmap. The number of reference and detected points must be three.

Use LBitmap::GetMarksCenterMass to fill the pRefPoints array with the points representing the center of masses for each of the reference marks from the reference bitmap.

Fill the pTrnsPoints array by performing the following steps:

Use LBitmap::SearchRegMarks to find the new positions for the reference marks.

Using LBitmap::GetMarksCenterMass to fill the pTrnsPoint array with points representing the center of masses for each of the transformed reference marks.

The values pnXTranslation, pnYTranslation, pnAngle, puXScale and puYScale are internally divided by 100. For example, a pnAngle of 500 would mean to rotate the bitmap 5 degrees clockwise.

The results of this function must be sent without any modification to the LBitmap::ApplyTransformationParameters function in order to correct the image.

If you want to correct the image yourself, you have to perform the inverse operations in this order:

  1. Shift the image by (-pXTranslation / 100, -pYTranslation / 100) using LBitmapBase::Combine.

  2. Rotate without resizing by (*pnAngle).

  3. Resize using scaling factors of (100 / *puXScale, 100 / *puYScale) using LBitmapBase::Size or LBitmapBase::Resize.

This function does not use LBase::EnableStatusCallback.

If you simply want to automatically straighten a bitmap, use the LBitmap::Deskew function.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

Get aRefPoints from pre-calculated saved values. You have to implement LoadRefParameters
LoadRefParameters(aRefPoints);
Then send the aRefPoints to this function.

L_INT LBitmap__GetTransformationParametersExample(LBitmap * pLeadBitmap, LPPOINT paRefPoints)  
 
{ 
   
   /* This example loads a bitmap, and computes the translation parameters. The example makes the assumption that you have saved the position of the registration marks of the reference bitmap in a file. It also assumes you have a function which loads these positions, namely,  'LoadRefParameters'. You should modify this example and replace LoadRefParameters with your own function before testing this example.  
 
   */ 
 
   L_INT nAngle;  
   L_INT nRet; 
   L_UINT  uXScale, uYScale;  
   L_INT  uXTranslation, uYTranslation;  
   SEARCHMARKS aSearchMarks[3];  
   POINT  aMarkPoints[3];  
   POINT  aMarkCMPoints[3];  
    
 
   /*Get registration marks CM*/ 
   aSearchMarks[0].uStructSize = sizeof(SEARCHMARKS);  
   aSearchMarks[0].uType = RGS_T;  
   aSearchMarks[0].uMinScale = 90;  
   aSearchMarks[0].uMaxScale = 110;  
   aSearchMarks[0].uWidth = 31;  
   aSearchMarks[0].uHeight = 29;  
   SetRect(&aSearchMarks[0].rcRect, 0,0,100,100);  
   aSearchMarks[0].uSearchMarkCount = 1;  
   aSearchMarks[0].pMarkDetectedPoints = (POINT  *)   
   malloc(aSearchMarks[0].uSearchMarkCount * sizeof(POINT));  
 
   aSearchMarks[1].uType = RGS_T;  
   aSearchMarks[1].uMinScale = 90;  
   aSearchMarks[1].uMaxScale = 110;  
   aSearchMarks[1].uWidth = 31;  
   aSearchMarks[1].uHeight = 29;  
   SetRect(&aSearchMarks[1].rcRect, 100,100,200,150);  
   aSearchMarks[1].uSearchMarkCount = 1;  
   aSearchMarks[1].pMarkDetectedPoints = (POINT  *)  malloc(aSearchMarks[1].uSearchMarkCount * sizeof(POINT));  
 
   aSearchMarks[2].uType = RGS_T;  
   aSearchMarks[2].uMinScale = 90;  
   aSearchMarks[2].uMaxScale = 110;  
   aSearchMarks[2].uWidth = 31;  
   aSearchMarks[2].uHeight = 29;  
   SetRect(&aSearchMarks[2].rcRect, 100,100,300,300);  
   aSearchMarks[2].uSearchMarkCount = 1;  
   aSearchMarks[2].pMarkDetectedPoints = (POINT  *)  malloc(aSearchMarks[2].uSearchMarkCount * sizeof(POINT));  
 
   nRet =pLeadBitmap->SearchRegMarks (aSearchMarks,3); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   aMarkPoints[0]= *aSearchMarks[0].pMarkDetectedPoints;  
   aMarkPoints[1]= *aSearchMarks[1].pMarkDetectedPoints;  
   aMarkPoints[2]= *aSearchMarks[2].pMarkDetectedPoints;  
 
   free(aSearchMarks[0].pMarkDetectedPoints);  
   free(aSearchMarks[1].pMarkDetectedPoints);  
   free(aSearchMarks[2].pMarkDetectedPoints);  
 
   nRet =pLeadBitmap->GetMarksCenterMass (aMarkPoints, aMarkCMPoints, 3); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =pLeadBitmap->GetTransformationParameters (paRefPoints, aMarkCMPoints, &uXTranslation, &uYTranslation, &nAngle, &uXScale, &uYScale); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =pLeadBitmap->ApplyTransformationParameters(uXTranslation, uYTranslation,nAngle, uXScale, uYScale, RGS_SIZE_BICUBIC | RGS_SIZE_FAVORWHITE); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   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++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.