L_RemoveRedeyeBitmap

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_RemoveRedeyeBitmap(pBitmap, rcNewColor, uThreshold, nLightness, uFlags)

Removes the "red eye" effect in color images by converting the red color in the eye to the new specified color.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that references the bitmap to be modified.

COLORREF rcNewColor

COLORREF variable that contains the new color value used to replace the red color in the eyes.

L_UINT uThreshold

Threshold value that indicates which pixels will be changed by this function. All pixels with a red component value greater than this value will be changed. Pixels with a red component value less than this value will not be changed. This value is between 0 and 255.

L_INT nLightness

"Percentage" value that indicates whether the pixels that are replaced are lightened or darkened. If this value is greater than 100, the replaced pixels will be lightened. If this value is less than 100, the replaced pixels will be darkened. This function preserves the lightness of the original pixels and substitutes the red color with the new color.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
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 has no effect on grayscale images, since there is no "red eye" problem in grayscale images.

To use this function the user should select a small region around the eye. Otherwise, the function will change all the red color in the image. This function also allows the user to replace the red color with a new color for the eyes that is nearest to the original color.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

This function supports 48 and 64-bit color 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.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a bitmap that has a red eye problem, creates an elliptical region, and applies the redeye removal function on it.

L_INT RemoveRedeyeBitmapExample() 
{ 
   L_INT nRet; 
   RECT rRgnRect;               /* Rectangle that defines the region */ 
   COLORREF  rcNewColor;  /* the new color of the eyes */ 
   BITMAPHANDLE Bitmap;/* Bitmap handle to hold the loaded image. */ 
 
   /* Load a bitmap */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("red_eye.cmp")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Specify a rectangle to define the region rounded the eye. This region is specified by the mouse on the IMGFEATR demo*/ 
   SetRect(&rRgnRect, 80, 20, 100, 40); 
   /* Create an elliptical region */ 
   nRet = L_SetBitmapRgnEllipse(&Bitmap, NULL, &rRgnRect, L_RGN_SET); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Specify the new color for eyes */ 
   rcNewColor  = RGB(5, 20, 10); 
   /* Apply the redeye removal function */ 
   nRet = L_RemoveRedeyeBitmap(&Bitmap, rcNewColor, 125, 100, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Free the region */ 
   nRet = L_FreeBitmapRgn(&Bitmap); 
   if(nRet !=SUCCESS) 
      return nRet; 
   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; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help