L_UserFilterBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_UserFilterBitmap (pBitmap, pFilter, uFlags);

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

pUSERFLT pFilter;

pointer to a structure

L_UINT32 uFlags;

flags

Filters the bitmap based on a user-defined filter / mask. This function is similar to the spatial and binary filter functions.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap on which to apply the effect.

pFilter

Pointer to an USERFLT structure that contains information about the mask to be applied.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

With this function you can create a user-defined filter and apply it to the image. The selected filter is passed as a parameter to this function. The filter has a rectangular form (matrix) where the values are user-defined. It allows the creation of simple customized filters, where each value found in matrix is multiplied by the corresponding pixel, and then the specified operation is performed on the results.

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.

When the filter is applied to pixels from the edge and you choose the sum operation, the edge rows and columns are duplicated. For example, if the pixel (-1, 5) is needed, the pixel (0, 5) is used instead.

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

LTIMGEFX

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, Linux.

See Also

Functions:

L_MaxFilterBitmap, L_MinFilterBitmap, L_AddBitmapNoise, L_SharpenBitmap, L_PosterizeBitmap, L_MosaicBitmap, L_EmbossBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_OilifyBitmap, L_SolarizeBitmap, L_WindowLevel, L_AddShadowBitmap, L_AllocFTArray, L_ChangeHueSatIntBitmap, L_ColorReplaceBitmap, L_ColorThresholdBitmap, L_DFTBitmap, L_DirectionEdgeStatisticalBitmap, L_FFTBitmap, L_FreeFTArray, L_FrqFilterBitmap, L_FrqFilterMaskBitmap, L_FTDisplayBitmap, L_GetBitmapStatisticsInfo, L_GetFeretsDiameter, L_GetObjectInfo, L_GetRgnContourPoints, L_GetRgnPerimeterLength, L_MathFunctionBitmap, L_RevEffectBitmap, L_SegmentBitmap, L_SubtractBackgroundBitmap, L_HighPassFilterBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

 

Removing Noise

Example

In this example the high pass filter will be applied using user defined matrix

L_INT UserFilterBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE  LeadBitmap; /* Bitmap handle for the image */ 
   pUSERFLT  pFilter;  
   L_INT  i, j;  
 
   /* Load a bitmap at its own bits per pixel  */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);  
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Allocate the user filter structure. And also we need a (3x3) matrix with 9 elements. */ 
   pFilter = (pUSERFLT)malloc(sizeof(USERFLT) + 9 * sizeof(L_INT));  
 
   /* Initialize the array with factor used to apply the high pass filter */ 
   for(i = 0; i < 3; i++) 
   { 
      for(j = 0; j < 3; j++) 
      { 
         if(j == 1 || i == 1)  
         { 
            if(j == 1 && i == 1)  
               pFilter->ufltMatrix[i * 3 + j] = 5;  
            else  
               pFilter->ufltMatrix[i * 3 + j] = -1;  
         } 
         else 
            pFilter->ufltMatrix[i * 3 + j] = 0;  
      } 
   } 
   pFilter->uStructSize = sizeof(USERFLT);  
   pFilter->ufltWidth = 3; 
   pFilter->ufltHeight = 3;  
   pFilter->ufltCenter.x = 1;  
   pFilter->ufltCenter.y = 1;  
   pFilter->ufltDivisor = 1;  
   pFilter->nfltOffset = 0;  
   pFilter->ufltFlag = UD_SUM;  
 
   /* Apply the high pass custom filter */ 
   nRet = L_UserFilterBitmap (&LeadBitmap, pFilter, 0);  
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* Free the filter */ 
   free(pFilter); 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   return SUCCESS; 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help