L_LTIMGCOR_API L_INT L_SetKaufmannRgnBitmap(pBitmap, pKaufmannProcBitmap, nRadius, nMinInput, nMaxInput, nRgnThreshold, ptRgnStart, bRemoveHoles, puPixelsCount, uCombineMode, uFlags);
Sets a Kaufmann region based on the color value at the specified point.
Pointer to the bitmap handle that references the bitmap.
Pointer to a bitmap handle to be updated with the bitmap resulting from this function. This bitmap handle must be empty when this function is called. If this bitmap handle is not empty when this function is called, the function will return an error.
Value that indicates the size of the neighborhood used for blurring each pixel of the bitmap. Blurring is performed internally to enhance the resulting image.
Value that specifies the images shadows to be mapped. This value is used internally to enhance the image prior to growing the region. Valid values range from 0 to 255 for 8-bit, 0 to 4095 for 12-bit and 0 to 65535 for 16-bit images, and from -32768 to 32767 for signed images.
Value that specifies the images highlights to be mapped. This value is used internally to enhance the image prior to growing the region. Valid values range from 0 to 255 for 8-bit, 0 to 4095 for 12-bit and 0 to 65535 for 16-bit images, and from -32768 to 32767 for signed images.
Value that specifies the stopping point for the region. Valid values range from 0 to 255 for 8-bit, 0 to 4095 for 12-bit and 0 to 65535 for 16-bit images.
A POINT structure that contains the starting point used to set the region. This function determines the color value of the pixel at this point in the bitmap referenced by
pBitmap. Using this color as a starting point and the value specified in
nRgnThreshold as a stopping point, the function "grows" a region.
A flag that indicates whether to remove any holes present in the region that is created internally. These holes are located inside the region, but are not included in the region. Possible values are:
|TRUE||Remove the region holes.|
|FALSE||Do not remove the region holes.|
Pointer to a variable to be updated with the number of pixels in the region created by this function.
The action to take regarding the existing bitmap region, if one is defined. For descriptions of the possible values, refer to Creating a Bitmap Region.
Reserved for future use. Must be 0.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
This function gets the color value of the point, specified in
ptRgnStart, in the bitmap referenced in
pBitmap. Using this color value as a starting point and the value specified in
nRgnThreshold as an ending point, this function grows a region. Since noise affects the region growing process, enhancement procedures, such as Gaussian blur, are performed prior to obtaining the color from the specified point and growing the region, to improve the process. When this function returns, the
pKaufmannProcBitmap contains the data from pBitmap, enhanced using the internal enhancing procedures, and the resulting region. This region is drawn on the image in pBitmap, but pBitmap itself is not changed. The area of the resulting region can be used to calculate the Kaufmann ratio (size of the corpus callosum / size of the brain sphere).
To calculate the Kaufmann ratio do the following:
Call this function to create the first region, based on the appropriate area of the image. You will have to manipulate the parameters of the function to get the exact region you want. Save the puPixelCount value for this first region.
Call the function once more to create a region for the second area. Save the puPixelCount value for this second region.
Now calculate the ratio of the sizes of the two regions.
For more information on how to calculate the brain ratio refer to the example below.
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.
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
Win32, x64, Linux.
L_INT SetKaufmannRgnBitmapExample(HWND hWnd)
/* Load a bitmap at its own bits per pixel */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL);
pt.x = BITMAPWIDTH(&Bitmap) >> 1;
pt.y = BITMAPHEIGHT(&Bitmap) >> 1;
// Converting the bitmap into 8 bit gray scale bitmap
nRet = L_GrayScaleBitmap(&Bitmap, 8);
// apply the function in order to get the pixels count of the first region.
nRet = L_SetKaufmannRgnBitmap(&Bitmap, NULL, 21, 54, 110, 13, pt, FALSE, &uFirstPixelCount, L_RGN_SET, 0);
// apply the function once more.
nRet = L_SetKaufmannRgnBitmap(&Bitmap, NULL, 29, 51, 229, 207, pt, TRUE, &uSecondPixelCount, L_RGN_SET, 0);
// print the ratio between the first and the second region.
_stprintf_s(szText,MAX_PATH,TEXT("%.3f"),uFirstPixelCount * 1.0 / uSecondPixelCount);
MessageBox(hWnd,szText, MAKE_IMAGE_PATH(TEXT("Ratio")), MB_OK);
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &Bitmap, FILE_BMP, 24, 0, NULL);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries