LBitmap::SetKaufmannRgn

#include "ltwrappr.h"

L_INT LBitmap::SetKaufmannRgn (pProcessedBitmap,nRadius,nMinInput,nMaxInput, nRgnThreshold, ptRgnStart,bRemoveHoles, puPixelsCount, uCombineMode, uFlags = 0)

pBITMAPHANDLE pProcessedBitmap;

/* 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

pProcessedBitmap

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.

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.

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 by this object. 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 pProcessedBitmap contains the data from this object's bitmap, enhanced using the internal enhancing procedures, and the resulting region. This region is drawn on the image in this object's bitmap, but the bitmap in this object 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 puPixelsCount value for this first region.

2.

Call the function once more to create a region for the second area. Save the puPixelsCount 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 LBase::EnableStatusCallback.

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 only in the Document/Medical 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

Functions:

LBitmapRgn::SetRgnColor, LBitmapRgn::SetRgnEllipse, LBitmapRgn::SetRgnBorder, LBitmapRgn::SetRgnCurve, LBitmapRgn::SetRgnFromMask, LBitmapRgn::SetRgnMagicWand, LBitmapRgn::SetRgnPolygon, LBitmapRgn::SetRgnRect, LBitmapRgn::SetRgnRoundRect, LBitmapRgn::SetRgnXForm, LBitmap::ChangeIntensity, LBitmap::GammaCorrect, LBitmap::ChangeContrast, LBitmap::StretchIntensity, LBitmap::RemapIntensity, LBitmap::ChangeHue, LBitmap::ChangeSaturation, LBitmap::HistoEqualize, LBitmap::WindowLevel, LBitmap::WindowLevelExt, LBitmap::HistoContrast, LBitmap::ColorLevel, LBitmap::GaussianFilter, LBitmapRgn::HolesRemovalRgn

Topics:

Creating a Bitmap Region

 

Raster Image Functions: Creating and Using a Region

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LBitmap__SetKaufmannRgnExample()
{
   POINT        pt;
   L_UINT       uFirstPixelCount;
   L_UINT       uSecondPixelCount;
   L_UCHAR   szText[20] = "\0";
   LBitmap      Bitmap;
   L_INT         nRet = 0 ;
   /* Load a bitmap at its own bits per pixel  */
   nRet = Bitmap.Load(MAKE_IMAGE_PATH(TEXT("Image3.dcm")),0,ORDER_BGRORGRAY,NULL,NULL) ;
   if (nRet != SUCCESS)
   {
      MessageBox(NULL,TEXT("Failed to load image!"), TEXT("Load Failure"), MB_OK | MB_ICONERROR);
      return nRet;
   }
  /* get the center of the bitmap */
   pt.x = BITMAPWIDTH(Bitmap.GetHandle()) >> 1;
   pt.y = BITMAPHEIGHT(Bitmap.GetHandle()) >> 1;
   // Converting the bitmap into 8 bit gray scale bitmap
   nRet =Bitmap.GrayScale() ;
   if(nRet !=SUCCESS)
      return nRet;
   // apply the function in order to get the pixels count of the first region.
   nRet =Bitmap.SetKaufmannRgn(NULL, 21, 54, 110, 13, pt, FALSE, (L_SIZE_T*)&uFirstPixelCount, L_RGN_SET) ;
   if(nRet !=SUCCESS)
      return nRet;
   // apply the function once more.
   nRet =Bitmap.SetKaufmannRgn(NULL, 29, 51, 229, 207, pt, TRUE, (L_SIZE_T*)&uSecondPixelCount, L_RGN_SET);
   if(nRet !=SUCCESS)
      return nRet;
   // print the ratio between the first and the second region.
   _gcvt_s((char*)szText,_CVTBUFSIZE,uFirstPixelCount * 1.0 / uSecondPixelCount, 3);
   MessageBox(NULL,(TCHAR *)szText, TEXT("Ratio"), MB_OK | MB_ICONINFORMATION);
   return SUCCESS;
}