L_SetBitmapRgnColorHSVRange

#include "l_bitmap.h"

L_LTDIS_API L_INT L_SetBitmapRgnColorHSVRange(pBitmap, hsvLower, hsvUpper, uCombineMode)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

HSVREF hsvLower;

/* minimum HSV color value */

HSVREF hsvUpper;

/* maximum HSV color value */

L_UINT uCombineMode;

/* action to take regarding the existing region */

Creates or updates the bitmap region by adding a region that consists of all the pixels that fall in the range hsvLower ... hsvUpper, inclusively.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap where the region is to be created or updated.

hsvLower

Structure that contains the minimum (inclusive) H,S, and V values. A pixel must have H,S, and V all greater than or equal to hsvLower and less than or equal to hsvUpper to be included in the region.

hsvUpper

Structure that contains the maximum (inclusive) H,S, and V values. A pixel must have H,S, and V all greater than or equal to hsvLower and less than or equal to hsvUpper to be included in the region.

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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

This function uses the HSV color model to set a region based on a color range.

It is useful for identifying all shades of a certain color. For example, L_SetBitmapRgnColorHSVRange could be used to set a region of all green colors including:

 

RGB(0,1,0)

 

 

RGB(0,2,0)

RGB(1,2,1)

 

RGB(0,3,0)

RGB(1,3,1)

RGB(2,3,2)

...

...

...

RGB(0,255,0)

RGB(1,255,1)

RGB(2,255,2)

 

The diagram shows how S and V affect the color green (H = 85)

To be added to the region a color must fall in the range hsvLower..hsvUpper. If you want to set a region for all red (and colors near red), you could specify hsvLower and hsvUpper as follows:

hsvLower(250,1,1)

hsvUpper(5,255,255)

Note that hue for hsvLower is 250 and hue for hsvUpper is 5. For a hue to fall in this range, it must be either 250, 251, 252, 253, 254, 255, 1, 2, 3, 4, or 5. Also, note that the hue values wrap from 255 back around to 1.

To update an existing region, specify how the new region is to be combined with the existing one. For descriptions of the possibilities, refer to Creating a Bitmap Region.

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.

Required DLLs and Libraries

LTDIS

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:

L_RemapBitmapHue, L_SetBitmapRgnColorRGBRange, L_RGBtoHSV, L_HSVtoRGB, L_SetBitmapRgnEllipse, L_SetBitmapRgnPolygon, L_SetBitmapRgnRect, L_SetBitmapRgnRoundRect

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Creating a Bitmap Region

 

Working with the Existing Bitmap Region

 

Saving a Region

 

Example

 L_INT SetBitmapRgnColorHSVRangeExample(pBITMAPHANDLE  pBitmap)
{
   HSVREF hsvLo, hsvHi;
   L_INT  nRet;

   hsvLo.uH = 75;
   hsvLo.uS = 40;
   hsvLo.uV = 40;

   hsvHi.uH = 95;
   hsvHi.uS = 255;
   hsvHi.uV = 255;

   nRet = L_SetBitmapRgnColorHSVRange(pBitmap, hsvLo, hsvHi, L_RGN_SET);
   if(nRet != SUCCESS)
      return nRet;

   return SUCCESS;
}