LBitmap::ObjectCounter

Summary

Gets the number of black objects in a binary image.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::ObjectCounter(uCount, uFlags = 0)

Parameters

L_UINT * uCount

Pointer to a variable to be updated with the number of black objects.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
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

Platforms

Win32, x64.

See Also

Functions

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; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.