2.6.6.3 imgEdge

Menu Information

Edge

Brief Information

Detect edges in image

Command Line Usage

1. imgedge t:=10;
2. imgedge t:=7 f:=shv img:=mat(1) oimg:=mat(2); 

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Threshold t

Input

int

0

Specifies the threshold value used to determine edge pixels. If the difference determined for a pixel is greater than this value, the pixel will be an edge pixel.

Input Matrix img

Input

Image

<active>

Specifies the image to be manipulated. The default input is the active image.

Output Image oimg

Output

Image

<input>

Specifies the output image. By default, the output image is the same as the input image. See the syntax here.

Edge Filter f

Input

int

lh

Specifies which edge detection filter to apply.

Option list

  • sv:Sobel vertical edges
Detects vertical edges with Sobel operator.
  • sh:Sobel horizontal edges
Detects horizontal edges with Sobel operator.
  • shv:Sobel horizontal & vertical edges
Detects horizontal and vertical edges with Sobel operator.
  • pv:Prewitt vertical edges
Detects vertical edges with Prewitt operator.
  • ph:Prewitt horizontal edges
Detects horizontal edges with Prewitt operator.
  • phv:Prewitt horizontal & vertical edges
Detects horizontal and vertical edges with Prewitt operator.
  • l1:Laplace 1 vertical & horizontal edges
Detects horizontal and vertical edges with Laplace operator.
  • l2:Laplace 2 general edges
Detects general edges with Laplace operator.
  • l3:Laplace 3 general edges
Detects general edges with Laplace operator, using a method different from Laplace 2 general edges.
  • ld:Laplace diagonal edges
Detects diagonal edges with Laplace operator.
  • lh:Laplace horizontal edges
Detects horizontal edges with Laplace operator.
  • lv:Laplace vertical edges
Detects vertical edges with Laplace operator.
  • gn:Gradient north edges
Detects north edges with gradient filter.
  • gne:Gradient north east edges

Detects northeast edges with gradient filter.

  • ge:Gradient east edges
Detects east edges with gradient filter.
  • gse:Gradient south east edges
Detects south edges with gradient filter.
  • gs:Gradient south edges
Detects south edges with gradient filter.
  • gsw:Gradient south west edges
Detects southwest edges with gradient filter.
  • gw:Gradient west edges
Detects west edges with gradient filter.
  • gnw:Gradient north west edges
Detects north edges with gradient filter.

Description

The imgEdge function detects edges in the input image using edge filters. Many types of filters are available for you to choose to process different images.

This X-Function works for both color images and grayscale images.

Examples

  • Code Sample
// Subtract background from a cell image then detect the cell edges.
//Create a new folder in the Project Explorer
pe_mkdir EdgeDetection path:=aa$;
pe_cd aa$;
//Create a matrix and import the cell image into it
window -t m;
fname$ = System.path.program$ +"samples\Image Processing and Analysis\cell.jpg";
impimage;
CellBk$ = %h;
//Create a matrix and import the background image into it
window -t m;
fname$ = System.path.program$ +"samples\Image Processing and Analysis\bgnd.jpg";
impimage;

//Subtract background and pre-processing
imgSimpleMath img2:=cellbk$ func:=4 x:=7 y:=13 crop:=1;
imgBinary t1:=65 t2:=255;
imgMedian d:=18;
//Edge detection
imgEdge t:=12 f:=shv;
//Add the edges back to the cell image
imgSimpleMath img2:=cellbk$ func:=3;

window -z; //Maximize window

Algorithm

The computation uses L_EdgeDetectorBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_EdgeDetectorBitmap topic.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgUserfilter