L_EdgeDetectorBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_EdgeDetectorBitmap(pBitmap, nThreshold, uFilter)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nThreshold;

/* threshold value */

L_UINT uFilter;

/* filter to be used */

Applies the specified edge filter to the specified bitmap.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap on which to apply the edge filter.

nThreshold

Threshold value used to determine which pixels are edge pixels. If the difference determined for a pixel is greater than this value, the pixel is an edge pixel.

uFilter

Flag that indicates which edge detection filter to apply. Possible values are:

 

Value

Meaning

 

EDG_SOBEL_VERT

[0x0101] Detect the vertical edges

 

EDG_SOBEL_HORZ

[0x0102] Detect the horizontal edges

 

EDG_SOBEL_ALL

[0x0103] Detect horizontal & vertical edges

 

EDG_PREWITT_VERT

[0x0201] Detect the vertical edges

 

EDG_PREWITT_HORZ

[0x0202] Detect the horizontal edges

 

EDG_PREWITT_ALL

[0x0203] Detect horizontal & vertical edges

 

EDG_LAPLACE_1

[0x0301] Detect vertical & horizontal edges

 

EDG_LAPLACE_2

[0x0302] Detect general edges

 

EDG_LAPLACE_3

[0x0303] Detect general edges. (The filter used for this option is different than the filter used for the EDG_LAPLACE_2 filter.)

 

EDG_LAPLACE_DIAG

[0x0304] Detect the diagonal edges

 

EDG_LAPLACE_HORZ

[0x0305] Detect the horizontal edges

 

EDG_LAPLACE_VERT

[0x0306] Detect the vertical edges

 

EDG_GRADIENT_N

[0x0401] Detect north edges

 

EDG_GRADIENT_NE

[0x0402] Detect north east edges

 

EDG_GRADIENT_E

[0x0403] Detect east edges

 

EDG_GRADIENT_SE

[0x0404] Detect south east edges

 

EDG_GRADIENT_S

[0x0405] Detect south edges

 

EDG_GRADIENT_SW

[0x0406] Detect south west edges

 

EDG_GRADIENT_W

[0x0407] Detect west edges

 

EDG_GRADIENT_NW

[0x0408] Detect north west edges

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Filters such as Sobel filter, Prewitt filter, Laplacian filter, and Gradient filter are used to determine the pixels belonging to edges in the bitmap.

This function can process the whole image or a region of the image.

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.

The threshold range for 16, 48 and 64-bit images is from 0 to 65535 for unsigned images, and from –32768 to +32767 for signed images. For 12-bit images, the threshold range is from 0 to 4095 for unsigned images, and from –2048 to +2047 for signed images. Otherwise, it is from 0 to 255. The threshold is applied to channels separately.

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

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_CombineBitmap, L_IntensityDetectBitmap, L_SharpenBitmap, L_SpatialFilterBitmap, L_SkeletonBitmap, L_CorrelationBitmap

Topics:

Detecting and Enhancing Edges and Lines

 

Raster Image Functions: Image Processing: Filtering Images

 

Raster Image Functions: Detecting and Enhancing Edges and Lines

Example

This example loads a bitmap and finds its edges.

 L_INT EdgeDetectorBitmapexample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* find the edges of the bitmap */
   nRet = L_EdgeDetectorBitmap (&LeadBitmap,60, EDG_SOBEL_ALL);
   if(nRet !=SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}