L_UnsharpMaskBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_UnsharpMaskBitmap(pBitmap, nAmount, nRadius, nThreshold, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

L_INT nAmount;

adjustment factor

L_INT nRadius;

radius of the mask

L_INT nThreshold;

threshold value

L_UINT uFlags;

flag

Sharpens the specified image by applying the unsharp mask.

Parameter Description
pBitmap Pointer to the bitmap handle that references the bitmap on which to apply the mask.
nAmount Value that represents an adjustment factor. This is a percentage.
nRadius Value that indicates the size of the neighborhood used for blurring each pixel of the bitmap.
nThreshold Value that indicates the threshold for modifying the original value of the pixel. If the difference in the original pixel value and the blurred pixel value is greater than the threshold value, the original pixel value will be modified. The valid range is from 0 - 65535 for 64-bit, 48-bit and 16-bit grayscale images and from 0 - 4095 for 12-bit grayscale images. Otherwise, it is from 0 to 255.
uFlags Flag that indicates the color space in which to apply the mask. Possible values are:
  Value Meaning
  RGB_SPACE [0x0001] Apply the mask in the RGB color space.
  YUV_SPACE [0x0002] Apply the mask in the YUV color space.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function is actually considered a sharpening function. It is used to sharpen the image with a minimum of noise. To reduce the noise, it starts by blurring a copy of the original image. The amount of blur depends on nRadius. The function then determines the difference between each pixel's value of the original image and the corresponding pixel's value in the blurred image. If the difference is greater than the nThreshold value, then the difference between the pixel values is multiplied by the value in the nAmount parameter and added to the original pixel value.

To increase the thickness of the sharpened edges, increase the value of nRadius.

To increase the amount of sharpness, increase the value of nAmount.

To reduce the noise and eliminate the small edges or individual pixels that will produce noise in image, increase the value of nThreshold.

Using the YUV color space decreases the processing time but some colors shift may happen.

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.

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_SharpenBitmap, L_PosterizeBitmap, L_MosaicBitmap, L_EmbossBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_OilifyBitmap, L_SolarizeBitmap, L_DlgUnsharpMask, L_WindowLevel, L_GaussianFilterBitmap, L_BricksTextureBitmap, L_DeskewBitmap, L_DiffuseGlowBitmap, L_GlowFilterBitmap, L_HalfTonePatternBitmap, L_HighPassFilterBitmap, L_MaskConvolutionBitmap, L_PerspectiveBitmap, L_PlasmaFilterBitmap, L_PointillistBitmap

Topics:

Raster Image Functions: Filtering Images

 

Detecting and Enhancing Edges and Lines

 

Raster Image Functions: Detecting and Enhancing Edges and Lines

Example

This example loads a bitmap and increases its sharpness. Load the bitmap, keeping the bits per pixel of the file

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT UnsharpMaskBitmapExample() 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap; 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_UnsharpMaskBitmap (&LeadBitmap, 200, 15, 50, RGB_SPACE); 
   if(nRet !=SUCCESS) 
      return nRet; 
   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 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