Gets the number of black objects in a binary image.
#include "ltwrappr.h"
virtual L_INT LBitmap::ObjectCounter(uCount, uFlags = 0)
Pointer to a variable to be updated with the number of black objects.
Reserved for future use. Must be 0.
Value | Meaning |
---|---|
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 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.
Win32, x64.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document