L_FrqFilterMaskBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_FrqFilterMaskBitmap(pMaskBitmap, pFTArray, bOnOff, uFlags)

pBITMAPHANDLE pMaskBitmap;

pointer to the Mask bitmap handle

pFTARRAY pFTArray;

pointer to structure

L_BOOL bOnOff;

flag

L_UINT32 uFlags;

flags

Creates a mask filter to remove specific frequency components from a bitmap.

Parameter Description
pMaskBitmap Pointer to the bitmap handle of the mask bitmap.
pFTArray Pointer to an FTARRAY structure. The acxData field is a two-dimensional array holding the frequency components.
bOnOff Value that indicates whether the frequency components are removed if the corresponding pixel value is zero. Possible values are:
  Value Meaning
  TRUE If the pixel value equals zero the frequency components in its location in acxData will be removed, otherwise no change. A component is "removed" when both members of the corresponding L_COMPLEX structure are set to 0.
  FALSE The frequency component in the pixel location in acxData will be multiplied by the value of the pixel divided by 255.
uFlags Reserved for future use. Must be 0.

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 is used only when you are dealing with Fourier Transform functions.

The Mask bitmap will be treated as grayscale bitmap. The (0,0) frequency located in mask bitmap center; positive X harmonics located in the right half of the mask bitmap and positive Y harmonics located in the lower half of the mask bitmap. Mask bitmaps dimensions must be equal to acxDatas dimensions.

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

This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.

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

LTIMGCOR

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_FFTBitmap, L_DFTBitmap, L_FTDisplayBitmap, L_FrqFilterBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_AddShadowBitmap, L_ChangeHueSatIntBitmap, L_ColorThresholdBitmap, L_DFTBitmap, L_AllocFTArray, 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_UserFilterBitmap, L_FragmentBitmap, L_HighPassFilterBitmap, L_UnsharpMaskBitmap

Topics:

Raster Image Functions: Fourier Transform

 

Removing Noise

Example

This example cleans noise from an input data. It assumes the two bitmaps being loaded. It also assumes the acxData field of pFTArray structure is large enough to hold the frequency components. See the example for L_FFTBitmap to see how to allocate the acxData field

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT FrqFilterMaskBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE MaskBitmap, NoisyBitmap; 
   pFTARRAY  pFTArray; 
   RECT rcRange; 
   /* Load the noisy bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &NoisyBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Load the mask bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE2.CMP")), &MaskBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /*Allocate FT buffer*/ 
   nRet = L_AllocFTArray(&NoisyBitmap, &pFTArray, sizeof(FTARRAY), 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   rcRange.left  = 0; 
   rcRange.right = NoisyBitmap.Width / 4; 
   rcRange.top = 0; 
   rcRange.bottom = NoisyBitmap.Height / 2; 
   /* Assume acxData field of pFTArray is the correct size*/ 
   /* apply DFT*/ 
   nRet = L_DFTBitmap(&NoisyBitmap, pFTArray, &rcRange, DFT_DFT | DFT_GRAY| DFT_RANGE| DFT_INSIDE_X| DFT_OUTSIDE_Y); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* filter frequencies */ 
   nRet = L_FrqFilterMaskBitmap(&MaskBitmap, pFTArray, TRUE, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* apply inverse DFT */ 
   /* After this call, the image should be clean */ 
   nRet = L_DFTBitmap(&NoisyBitmap, pFTArray, NULL, DFT_IDFT | DFT_ALL| DFT_IDFT_SCL|DFT_IDFT_BOTH|DFT_GRAY); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmaps 
   if(MaskBitmap.Flags.Allocated ) 
      L_FreeBitmap(&MaskBitmap); 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &NoisyBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap 
   if(NoisyBitmap.Flags.Allocated) 
      L_FreeBitmap(&NoisyBitmap); 
   L_FreeFTArray(pFTArray, 0); 
   return SUCCESS; 
} 

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