LBitmap::GetTransformationParameters
#include "ltwrappr.h"
virtual L_INT LBitmap::GetTransformationParameters (pRefPoints, pTrnsPoints, pnXTranslation, pnYTranslation,pnAngle, puXScale, puYScale)
POINT * pRefPoints; |
/* pointer to an array of reference points */ |
POINT * pTrnsPoints; |
/* pointer to an array of transformed points */ |
L_INT * pnXTranslation; |
/* pointer to a variable to be updated */ |
L_INT * pnYTranslation; |
/* pointer to a variable to be updated */ |
L_INT * pnAngle; |
/* pointer to a variable to be updated */ |
L_UINT * puXScale; |
/* pointer to a variable to be updated */ |
L_UINT * puYScale; |
/* pointer to a variable to be updated */ |
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. This function is available in the Document/Medical Toolkits.
Parameter |
Description |
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. |
pTrnsPoints |
Pointer to an array of transformed points. These points are the center of mass points in pBitmap. You have to provide this information. |
pnXTranslation |
Pointer to a variable to be updated by the bitmap x-translation, in hundredths of pixels. |
pnYTranslation |
Pointer to a variable to be updated by the bitmap y-translation, in hundredths of pixels. |
pnAngle |
Pointer to a variable to be updated with the bitmap rotation angle, in hundredths of degrees. |
puXScale |
Pointer to a variable to be updated with the bitmap x-scaling (resizing), in percent. |
puYScale |
Pointer to a variable to be updated with the bitmap y-scaling (resizing), in percent. |
Returns
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 peforming 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
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. |
See Also
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[0].rcRect, 200,150,100,100); 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[0].rcRect, 300,300,100,100); 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; }