Available in LEADTOOLS Medical Imaging toolkits. |
L_SetKaufmannRgnBitmap
#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_SetKaufmannRgnBitmap(pBitmap, pKaufmannProcBitmap, nRadius, nMinInput, nMaxInput, nRgnThreshold, ptRgnStart, bRemoveHoles, puPixelsCount, uCombineMode, uFlags);
pBITMAPHANDLE pBitmap; |
/* pointer to a bitmap handle */ |
pBITMAPHANDLE pKaufmannProcBitmap; |
/* pointer to the processed bitmap handle */ |
L_INT nRadius; |
/* blur radius */ |
L_INT nMinInput; |
/* minimum leveling input */ |
L_INT nMaxInput; |
/* maximum leveling input */ |
L_INT nRgnThreshold; |
/* region threshold */ |
POINT ptRgnStart; |
/* region starting point */ |
L_BOOL bRemoveHoles; |
/* flag that indicates whether to remove holes */ |
L_SIZE_T* puPixelsCount; |
/* pointer to a variable to be updated */ |
L_UINT uCombineMode; |
/* action to take regarding the existing region */ |
L_UINT32 uFlags; |
/* flags */ |
Sets a Kaufmann region based on the color value at the specified point.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle that references the bitmap. |
|
pKaufmannProcBitmap |
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. |
|
nRadius |
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. |
|
nMinInput |
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. |
|
nMaxInput |
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.. |
|
nRgnThreshold |
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. |
|
ptRgnStart |
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. |
|
bRemoveHoles |
A flag that indicates whether to remove any holes present in the region thats created internally. These holes are located inside the region, but are not included in the region. Possible values are: |
|
|
Value |
Meaning |
|
TRUE |
Remove the region holes. |
|
FALSE |
Dont remove the region holes. |
puPixelsCount |
Pointer to a variable to be updated with the number of pixels in the region created by this function. |
|
uCombineMode |
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. |
|
uFlags |
Reserved for future use. Must be 0. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
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:
1. |
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. |
2. |
Call the function once more to create a region for the second area. Save the puPixelCount value for this second region. |
3. |
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
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. |
Platforms
Win32, x64.
See Also
Example
#if defined (LEADTOOLS_V16_OR_LATER) L_INT SetKaufmannRgnBitmapExample(HWND hWnd) { L_INT nRet; POINT pt; L_SIZE_T uFirstPixelCount; L_SIZE_T uSecondPixelCount; L_TCHAR szText[MAX_PATH]; BITMAPHANDLE Bitmap; /* 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); if(nRet !=SUCCESS) return nRet; pt.x = BITMAPWIDTH(&Bitmap) >> 1; pt.y = BITMAPHEIGHT(&Bitmap) >> 1; // Converting the bitmap into 8 bit gray scale bitmap nRet = L_GrayScaleBitmap(&Bitmap, 8); if(nRet !=SUCCESS) return nRet; // 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); if(nRet !=SUCCESS) return nRet; // apply the function once more. nRet = L_SetKaufmannRgnBitmap(&Bitmap, NULL, 29, 51, 229, 207, pt, TRUE, &uSecondPixelCount, L_RGN_SET, 0); if(nRet !=SUCCESS) return nRet; // 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); if(nRet !=SUCCESS) return nRet; //free bitmap if(Bitmap.Flags.Allocated) L_FreeBitmap(&Bitmap); return SUCCESS; } #else L_INT SetKaufmannRgnBitmapExample(HWND hWnd) { L_INT nRet; POINT pt; L_SIZE_T uFirstPixelCount; L_SIZE_T uSecondPixelCount; L_TCHAR szText[MAX_PATH]; BITMAPHANDLE Bitmap; /* 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); if(nRet !=SUCCESS) return nRet; pt.x = BITMAPWIDTH(&Bitmap) >> 1; pt.y = BITMAPHEIGHT(&Bitmap) >> 1; // Converting the bitmap into 8 bit gray scale bitmap nRet = L_GrayScaleBitmap(&Bitmap, 8); if(nRet !=SUCCESS) return nRet; // 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); if(nRet !=SUCCESS) return nRet; // apply the function once more. nRet = L_SetKaufmannRgnBitmap(&Bitmap, NULL, 29, 51, 229, 207, pt, TRUE, &uSecondPixelCount, L_RGN_SET); if(nRet !=SUCCESS) return nRet; // 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("Ratio")), &Bitmap, FILE_BMP, 24, 0, NULL); if(nRet !=SUCCESS) return nRet; //free bitmap if(Bitmap.Flags.Allocated) L_FreeBitmap(&Bitmap); return SUCCESS; } #endif // LEADTOOLS_V16_OR_LATER