L_GetTransformationParameters
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_GetTransformationParameters (pBitmap, pRefPoints, pTrnsPoints, pnXTranslation, pnYTranslation,pnAngle, puXScale, puYScale)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
POINT L_FAR * pRefPoints; |
/* pointer to an array of reference points */ |
POINT L_FAR * pTrnsPoints; |
/* pointer to an array of transformed points */ |
/* pointer to a variable to be updated */ | |
/* pointer to a variable to be updated */ | |
/* pointer to a variable to be updated */ | |
/* pointer to a variable to be updated */ | |
/* 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 |
pBitmap |
Pointer to the bitmap handle referencing the transformed bitmap. |
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 L_GetMarksCenterMassBitmap 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 L_SearchRegMarksBitmap to find the new positions for the reference marks
Using L_GetMarksCenterMassBitmap 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 L_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 L_CombineBitmap or L_CombineBitmapExt |
2. |
Rotate without resizing by – (*pnAngle) |
3. |
Resize using scaling factors of (100 / *puXScale, 100 / *puYScale) using L_SizeBitmap or L_ResizeBitmap |
This function does not use L_SetStatusCallback.
If you simply want to automatically straighten a bitmap, use the L_DeskewBitmap 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.
Required DLLs and Libraries
LTIMG 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
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Functions: |
L_CombineBitmap, L_RotateBitmap, L_SizeBitmap, L_ResizeBitmap, L_IsRegMarkBitmap, L_SearchRegMarksBitmap, L_GetMarksCenterMassBitmap |
Topics: |
|
|
Example
/* 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.
*/
BITMAPHANDLE LeadBitmap; // Bitmap handle for the image
L_INT nAngle;
L_UINT uXScale, uYScale, uXTranslation, uYTranslation;
SEARCHMARKS aSearchMarks[3];
POINT aMarkPoints[3];
POINT aMarkCMPoints[3];
POINT aRefPoints[3];
POINT CenterPt;
// Load a bitmap at its own bits per pixel
L_LoadBitmap (TEXT("e:\\IMAGE3.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
// bend the image around it is center
CenterPt.x = LeadBitmap.Width/2;
CenterPt.y = LeadBitmap.Height/2;
/* Get aRefPoints from pre-calculated saved values. You have to implement LoadRefParameters */
LoadRefParameters(aRefPoints);
/*Get registration marks CM*/
SET_SIZE(&aSearchMarks[0]);
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 L_FAR *)
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 L_FAR *) 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 L_FAR *) malloc(aSearchMarks[2].uSearchMarkCount * sizeof(POINT));
L_LoadBitmap (TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
L_SearchRegMarksBitmap (&LeadBitmap,aSearchMarks,3);
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);
L_GetMarksCenterMassBitmap (&LeadBitmap, aMarkPoints, aMarkCMPoints, 3);
L_GetTransformationParameters (&LeadBitmap, aRefPoints, aMarkCMPoints, &uXTranslation, &uYTranslation, &nAngle, &uXScale, &uYScale);
L_ApplyTransformationParameters (&LeadBitmap, uXTranslation, uYTranslation,nAngle, uXScale, uYScale, SIZE_BICUBIC);