LEADTOOLS Raster Imaging C++ Class Library Help > Classes and Member Functions > LBitmap > LBitmap Member Functions > LBitmap::ObjectCounter |
#include "ltwrappr.h"
L_INT LBitmap::ObjectCounter(uCount, uFlags = 0)
L_UINT * uCount; |
/* objects count */ |
L_UINT32 uFlags; |
/* flags */ |
Gets the number of black objects in a binary image.
Parameter |
Description |
uCount |
Pointer to a variable to be updated with the number of black objects. |
uFlags |
Reserved for future use. Must be 0. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If white objects are on a black image, the colors in the class object's bitmap must be inverted by calling LBitmap::Invert 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
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.
See Also
Functions: |
LBitmap::DeleteObjectInfo, LBitmap::EndFastMagicWandEngine, LBitmap::ObjectCounterCallback, LBitmap::StartFastMagicWandEngine |
Topics: |
|
|
Example
//This example counts black binary objects in a binary image with a white background
//The objects can be of any size or shape
//The callback member function is used to show the length of each removed rake
//The callback member function does NOT receive a Windows region.
class LObjectCounterBitmap : public LBitmap { public: LObjectCounterBitmap(); ~LObjectCounterBitmap(); virtual L_INT LObjectCounterBitmap::ObjectCounterCallBack(L_RECT rect ); }; LObjectCounterBitmap::LObjectCounterBitmap() { } LObjectCounterBitmap::~LObjectCounterBitmap() { } L_INT LObjectCounterBitmap::ObjectCounterCallBack(L_RECT rect ) { CString strMsg; strMsg.Format( TEXT("Region Bounds: left=%d, right=%d, top=%d, bottom=%d \n count=%d"), rect.left, rect.right, rect.top, rect.bottom ); OutputDebugString(strMsg); return SUCCESS; } L_INT LBitmap__ObjectCounterExample(LBitmapWindow *pBitmapWindow) { L_UINT uCount; L_INT nRet; CString strMsg; nRet = pBitmapWindow->ObjectCounter(&uCount, 0); strMsg.Format( TEXT("The number of Objects is: %d"), uCount ); return SUCCESS; }