L_AutoZoneBitmap
#include "l_bitmap.h"
L_LTIMGCOR_API L_INT EXT_FUNCTION L_AutoZoneBitmap(pBitmap, phZones, puCount, uFlags, pCallback, pUserData)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
HGLOBAL * phZones; |
/* pointer of a handle to be updated with the detected zones */ |
L_UINT32 * puCount; |
/* the count of detected zones */ |
L_UINT32 uFlags; |
/* flags */ |
AUTOZONECALLBACK pCallback; |
/* optional callback function */ |
L_VOID * pUserData; |
/* pointer to more parameters for the callback */ |
Detects different zone types (Text, Graphic and Table) in an image automatically. This is an important feature for OCR pre-processing to improve the recognition results. This function is useful for any application that needs to automatically separate images, tables and text within mixed raster content (MRC) images.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap in which the zones will be detected. |
|
phZones |
Pointer to a handle to be updated with the detected zones. To retrieve data of the detected zones cast the phZones to pLEADZONE and call GlobalLock function. |
|
puCount |
Pointer to a variable to be updated with the number of detected zones. |
|
uFlags |
Flags that indicate the detection behavior of the function. The following flags indicate the type of zones to be detected. You can combine values when appropriate by using a bitwise OR ( | ). Possible values are: |
|
|
Value |
Meaning |
|
AUTOZONE_DETECT_TEXT |
[0x0001] Detects text zones. |
|
AUTOZONE_DETECT_GRAPHIC |
[0x0002] Detects graphic zones. |
|
AUTOZONE_DETECT_TABLE |
[0x0004] Detects table zones. |
|
AUTOZONE_DETECT_ALL |
[0x0007] Detects all zone types (Text, Graphics and tables). |
|
Flags indicate whether to allow overlapping among zones: |
|
|
Value |
Meaning |
|
AUTOZONE_DONT_ALLOW_OVERLAP |
[0x0000] Dont allow zones to overlap. |
|
AUTOZONE_ALLOW_OVERLAP |
[0x0010] Allow zones to overlap. |
|
Flags indicate the merging type among text zones: |
|
|
Value |
Meaning |
|
AUTOZONE_ACCURATE_ZONES |
[0x0000] Dont merge text zones and keep them separated (paragraphs). |
|
AUTOZONE_GENERAL_ZONES |
[0x0100] Merge text zones to the maximum. |
|
Flags indicate the table zones detection options: |
|
|
Value |
Meaning |
|
AUTOZONE_DONT_RECOGNIZE_ONE_CELL_TABLE |
[0x0000] Ignore one-cell tables (borders), and detect what inside. |
|
AUTOZONE_RECOGNIZE_ONE_CELL_TABLE |
[0x1000] Consider borders as one-cell tables. |
|
Flags indicate whether to use multi-threading: |
|
|
Value |
Meaning |
|
AUTOZONE_USE_MULTITHREADING |
[0x00000000] Use multi-threading (that will be faster with a multi-core CPUs). |
|
AUTOZONE_DONTUSE_MULTITHREADING |
[0x80000000] Dont Use multi-threading (that will be used with a single-core CPUs) |
pCallback |
Optional callback function for additional processing. |
|
|
|
|
|
|
|
|
The callback function must adhere to the function prototype described in AUTOZONECALLBACK Function. |
|
pUserData |
Void pointer that you can use to pass one or more additional parameters that the callback function needs. |
|
|
To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. |
|
|
If the additional parameters are not needed, you can pass NULL in this parameter. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
After using this function the phZones should be freed using the L_FreeZoneData function.
To update a status bar or detect a user interrupt during execution of this function, see the L_SetStatusCallback function.
This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.
This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
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. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP
See Also
Example
Detects the image zones and return the results.
L_INT AutoZoneBitmapExample(L_VOID) { L_INT nRet; BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */ HGLOBAL pointer = NULL; L_UINT32 count; L_INT TextZonesCount = 0; L_INT GraphicZonesCount = 0; L_INT TableZonesCount = 0; L_INT CellsCount = 0; L_UINT i; nRet = L_LoadBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\Clean.tif"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet !=SUCCESS) return nRet; nRet = L_AutoZoneBitmap( &LeadBitmap, &pointer, &count, 0, NULL, NULL); if(nRet !=SUCCESS) return nRet; LEADZONE * pZone = (LEADZONE *)GlobalLock(pointer); for(i=0; i<count; i++) { if (pZone[i].uZoneType == LEAD_ZONE_TYPE_TEXT) { TextZonesCount++; } if (pZone[i].uZoneType == LEAD_ZONE_TYPE_GRAPHIC) { GraphicZonesCount++; } if (pZone[i].uZoneType == LEAD_ZONE_TYPE_TABLE) { TableZonesCount++; TABLEZONE * pTable = (TABLEZONE *)GlobalLock(pZone[i].pZoneData); CellsCount = pTable->Rows * pTable->Columns; GlobalUnlock(pTable); } } nRet = L_FreeZoneData(pointer, count); if(nRet !=SUCCESS) return nRet; GlobalUnlock(pointer); if(LeadBitmap.Flags.Allocated) L_FreeBitmap(&LeadBitmap); return SUCCESS; }