LBitmap::AddWeighted

Summary

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

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::AddWeighted (hBitmapList, puFactor, uFlags)

virtual L_INT LBitmap::AddWeighted (pBitmapList, puFactor, uFlags)

Parameters

HBITMAPLIST hBitmapList

Handle to the list of bitmaps.

L_UINT * 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.

L_UINT 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.

LBitmapList * pBitmapList

Pointer to the bitmap list object.

Returns

Value Meaning
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.

If uFlags is BC_ADD, the function can be used to add several images of the same view to improve the lightness or brightness of the image. In this case, puFactor is ignored.

If uFlags is BC_AVG, the function can be used to average several images. In this case, puFactor is ignored.

If uFlags is BC_ADDWEIGHTED, the function can be used to obtain an image as the sum of several weighted images. Each bitmap in any position in the list has a corresponding weight factor in the same position in the puFactor array. The real values are the weight factors divided by 100. For Example if a weight factor is 131 its real value is 1.31. If puFactor equals NULL, each bitmap has the same weight factor of 100 and the result is the same as for BC_ADD.

If uFlags is BC_AVGWEIGHTED, the function can eliminate random noise by performing a weighted average. Each bitmap in any position in the list has a corresponding weight factor in the puFactor array. The real values are the weight factors in the array divided by 100. The weighted sum will be divided by the sum of the weights. If puFactor equals NULL, each bitmap has the same weight factor of 100 and the result is the same as for BC_AVG.

The result of the operation will be stored in this class.

This function performs operations between data byte-by-byte. An image can be any color resolution. 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 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.

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

Add Weighted Bitmaps Function - Before

Add Weighted Bitmaps Function - Before

Add-Weighted-Bitmaps Function - After

Add-Weighted-Bitmaps Function - After

View additional platform support for this Add-Weighted-Bitmaps function.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmap__AddWeightedExample(LAnimationWindow * LAniWnd)  
{ 
   L_INT nRet; 
   LBitmapList BitmapList;  
   LBitmapBase Bitmap, PaintBitmap;  
    
   nRet =BitmapList.Create(); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =Bitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image1.jpg")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =BitmapList.InsertItem(&Bitmap); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =Bitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image2.jpg")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =BitmapList.InsertItem(&Bitmap); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =Bitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.jpg")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =BitmapList.InsertItem (&Bitmap); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =Bitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\NaturalFruits.jpg")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet =BitmapList.InsertItem (&Bitmap); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   nRet =LAniWnd->AddWeighted(&BitmapList,NULL, BC_AVG); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
}  
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.