#include "ltwrappr.h"
L_INT LBitmap::AutoZone(phZones, puCount, uFlags = 0)
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 |
Automatically detects different zone types (Text, Graphics and Tables) in an image (doing so improves recognition results for OCR pre-processing).
Parameter | Description | |
phZones | Pointer to a handle to be updated with the detected zones. To retrieve the data of the detected zones cast the phZones to pLEADZONE and call the GlobalLock function. | |
puCount | Pointer to a variable to be updated with the number of detected zones. | |
uFlags | Flags indicating how the function should behave. You can combine values when appropriate by using a bitwise OR ( | ). Possible values are: | |
Flags indicating which types of zones to detect: (one of these is mandatory) | ||
Value | Meaning | |
AUTOZONE_DETECT_TEXT | [0x0001] Detect text zones. | |
AUTOZONE_DETECT_GRAPHIC | 0x0002] Detect graphic zones. | |
AUTOZONE_DETECT_TABLE | [0x0004] Detect table zones. | |
AUTOZONE_DETECT_ALL | [0x0007] Detect all zone types (Text, Graphics and tables). | |
Flags indicating whether to allow overlapping among zones: (Optional) | ||
Value | Meaning | |
AUTOZONE_DONT_ALLOW_OVERLAP | [0x0000] Do not allow zones to overlap. | |
AUTOZONE_ALLOW_OVERLAP | [0x0010] Allow zones to overlap. | |
Flags indicating how to merge text zones: (Optional) | ||
Value | Meaning | |
AUTOZONE_ACCURATE_ZONES | [0x0000] Do not merge text zones. Keep them separated (as paragraphs). | |
AUTOZONE_GENERAL_ZONES | [0x0100] Merge text zones as much as possible. | |
Flags indicating options for table zone detection: (Optional) | ||
Value | Meaning | |
AUTOZONE_DONT_RECOGNIZE_ONE_CELL_TABLE | [0x0000] Ignore one-cell tables (borders). Detect what is inside. | |
AUTOZONE_RECOGNIZE_ONE_CELL_TABLE | [0x1000] Consider borders to be one-cell tables. | |
AUTOZONE_NORMAL_TABLE (version 17 or after) | [0x0000] Use normal table detection. | |
AUTOZONE_ADVANCED_TABLE (version 17 or after) | [0x2000] Use advanced table detection which is more accurate and which can detect complex tables. | |
AUTOZONE_LINES_RECONSTRUCTION (version 17 or after) | [0x4000] Use line reconstruction to connect broken lines and for patterned tables. | |
Flags indicating whether to use multi-threading: (Optional) | ||
Value | Meaning | |
AUTOZONE_USE_MULTITHREADING | [0x00000000] Use multi-threading (faster for multi-core CPUs). | |
AUTOZONE_DONTUSE_MULTITHREADING | [0x80000000] Do not use multi-threading (Use this with single-core CPUs). | |
Flags indicating the bitmap should be changed so all it contains is the text: (Optional) | ||
Value | Meaning | |
AUTOZONE_TEXT_DETECTION |
[0x8000] If set, the function does not return text zones in phZones. Instead, it modifies pBitmap to have text areas only: graphics and tables areas are deleted from the input image.
NOTE: Make a copy of the original image if you want to keep it, since when this function is set to AUTOZONE_TEXT_DETECTION the original image is modified. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
This function is useful for any application that needs to automatically separate images, tables and text within mixed raster content (MRC) images.
After using this function, free the phZones using the LBitmap::FreeZoneData 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_SIGNED_DATA_NOT_SUPPORTED error code if a signed data image is passed to this function.
This function does not support 32-bit grayscale images. It returns the ERROR_GRAY32_UNSUPPORTED error code if a 32-bit grayscale image is passed to this function.
The behavior of this function can be modified by overriding LBitmap::AutoZoneCallback.
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. |
Win32, x64.
Functions: |
LBitmap::AutoZoneCallback, LBitmap::FreeZoneData, Class Members |
Topics: |
Detects the image zones and return the results.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LBitmap__AutoZoneBitmapExample(LBitmap & LeadBitmap)
{
L_INT nRet;
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 = LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("Clean.tif")));
if(nRet !=SUCCESS)
return nRet;
nRet = LeadBitmap.AutoZone(&pointer, &count, 0);
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 = LeadBitmap.FreeZoneData(pointer, count);
if(nRet !=SUCCESS)
return nRet;
GlobalUnlock(pointer);
return SUCCESS;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET