#include "l_bitmap.h"
L_LTIMGCOR_API L_INT EXT_FUNCTION L_ObjectCounter(pBitmap, uCount, pCallback, pUserData, uFlags)
pBITMAPHANDLE pBitmap; |
pointer to bitmap |
L_UINT * uCount; |
variable to be updated with the objects count |
OBJECTCOUNTERCALLBACK pCallback; |
optional callback function |
L_VOID * pUserData; |
pointer to more parameters of the callback |
L_UINT32 uFlags; |
flags |
Gets the number of black objects in a binary image.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the binary image. |
uCount |
Pointer to a variable to be updated with the number of black objects. |
pCallback |
Optional callback function for additional processing. |
|
If you do not provide a callback function, use NULL as the value of this parameter. |
|
If you do provide a callback function, use the function pointer as the value of this parameter. |
|
The callback function must adhere to the function prototype described in OBJECTCOUNTERCALLBACK 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. |
uFlags |
Reserved for future use. Must be 0. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
If white objects are on a black image, the colors in the specified bitmap must be inverted by calling L_InvertBitmap function.
This function only works on 1-bit images.
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
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, Linux.
Functions: |
L_DeleteObjectInfo, L_EndFastMagicWandEngine, L_FastMagicWand, L_StartFastMagicWandEngine, L_SetBitmapRgnMagicWand |
Topics: |
|
|
This example loads a bitmap and counts the objects in it and prints the parameters of the rectangle\ surrounding the region
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT EXT_CALLBACK ObjectCounterExampleCB(L_RECT rect, L_INT **pObject, L_VOID *pUserData)
{
UNREFERENCED_PARAMETER(pUserData);
UNREFERENCED_PARAMETER(pObject);
L_TCHAR szMsg[200];
wsprintf(
szMsg,
TEXT("Region Bounds: left=%d, right=%d, top=%d, bottom=%d \n count=%d"),
rect.left, rect.right, rect.top, rect.bottom);
MessageBox(NULL, szMsg, TEXT(""), MB_OK);
return SUCCESS;
}
L_INT ObjectCounterExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap; /*Bitmap handle to hold the loaded image*/
L_UINT uCount; /*variable to hold the count*/
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image4.tif")),
&LeadBitmap, sizeof(BITMAPHANDLE), 0,
ORDER_BGR,NULL, NULL);
if(nRet != SUCCESS)
return nRet;
if (LeadBitmap.BitsPerPixel != 1)
return ERROR_BITPERPIXEL;
//Apply Object Counter
nRet = L_ObjectCounter(&LeadBitmap, &uCount, ObjectCounterExampleCB, NULL, 0);
if(nRet != SUCCESS)
return nRet;
//free bitmap
if(LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
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