L_AddWeightedBitmaps

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_AddWeightedBitmaps(pBitmap, uStructSize, hList, puFactor, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT uStructSize;

/* size of the BITMAPHANDLE structure */

HBITMAPLIST hList;

/* handle to the list of bitmaps */

L_UINT *puFactor;

/* array of weight factors */

L_UINT uFlags;

/* operation flag */

Adds or averages the bitmaps in a list according to their weight factors.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the resulting bitmap.

uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).

hList

Handle to the list of bitmaps.

puFactor

Array of unsigned integer values that represent weights associated with the bitmaps in the specified list. Used only if uFlags is BC_ADDWEIGHTED or BC_AVGWEIGHTED.

uFlags

Flag that indicates the operation to perform. Possible values are:

 

Value

Meaning

 

BC_AVG

[0x0001] Average the bitmaps in the specified list.

 

BC_ADD

[0x0002] Add the bitmaps in the specified list.

 

BC_AVGWEIGHTED

[0x0003] Average the bitmaps in the specified list, according to the array of weight factors, puFactor.

 

BC_ADDWEIGHTED

[0x0004] Add the bitmaps in the specified list, according to the array of weight factors, puFactor.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function can be used to modify the brightness (with the add operations) or remove the noise (with the average operations). Typically, you would call this function for a series of images taken of the same object at short intervals.

The sign flag in the BITMAPHANDLE structure must be the same for all images listed. That is, all hList images must be either signed or unsigned.

If the value of uFlags parameter is:

This function performs operations between data byte-by-byte. An image can be any color resolution. The resulting image of this operation will be allocated in the pBitmap where it is internally copied from the first image in the list. The operations are performed based on the smallest width and height of the input images.

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.

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

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

LTIMGCLR

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

Windows 2000 / XP/Vista.

See Also

Functions:

L_UnderlayBitmap, L_AddBitmaps, L_ChannelMix, L_DeinterlaceBitmap, L_DesaturateBitmap, L_EdgeDetectStatisticalBitmap, L_LightControlBitmap, L_SmoothEdgesBitmap, L_AutoColorLevelBitmap, L_ColorLevelBitmap, L_CorrelationBitmap, L_GrayScaleToDuotone, L_GrayScaleToMultitone, L_HolesRemovalBitmapRgn, L_SelectiveColorBitmap, L_SkeletonBitmap, L_BricksTextureBitmap, L_CanvasBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_VignetteBitmap, L_AdjustBitmapTint, L_GammaCorrectBitmapExt, L_HighPassFilterBitmap, L_UnsharpMaskBitmap

Topics:

Raster Image Functions: Combining Images

 

Raster Image Functions: Modifying Intensity Values

 

Processing an Image

 

Changing Brightness and Contrast

 

Raster Image Functions: Changing Brightness and Contrast

 

Removing Noise

Example

This example creates a bitmap list from one loaded bitmap, rotating each copy by 72 degrees than others, then average them

 L_INT AddWeightedBitmapsExample(L_VOID)
{
   L_INT nRet;
   HBITMAPLIST hList;  /* Bitmap list */
   BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
   BITMAPHANDLE TmpBitmap; /* Temporary bitmap for manipulating the list */
   BITMAPHANDLE ResultBitmap; /* Resulting bitmap */
   L_INT i; /* Loop counter */
   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   
   /* Create and populate the bitmap list */
   nRet = L_CreateBitmapList (&hList); 
   if(nRet !=SUCCESS)
      return nRet;
   for (i = 0; i < 4; i++)
   {
      nRet = L_CopyBitmap (&TmpBitmap, &LeadBitmap, sizeof(BITMAPHANDLE));
      if(nRet !=SUCCESS)
         return nRet;
      nRet = L_RotateBitmap (&TmpBitmap, i*720, ROTATE_RESAMPLE, RGB(255, 0, 0));
      if(nRet !=SUCCESS)
         return nRet;
      nRet = L_InsertBitmapListItem (hList, (L_UINT)-1, &TmpBitmap);
      if(nRet !=SUCCESS)
         return nRet;
   }

   /*take the average between all rotated bitmaps, and put the result in the ResultBitmap */
   nRet = L_AddWeightedBitmaps (&ResultBitmap, sizeof(BITMAPHANDLE), hList, NULL, BC_AVG);
   if(nRet !=SUCCESS)
      return nRet;
    
   nRet = L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);
   L_DestroyBitmapList(hList);
   return SUCCESS;
}