Skip to content

frei_dirFreiDirFreiDirfrei_dirfrei_dir🔗

Short description🔗

frei_dirFreiDirFreiDirfrei_dirfrei_dir — Detect edges (amplitude and direction) using the Frei-Chen operator.

Signature🔗

frei_dir( image Image, out image ImageEdgeAmp, out image ImageEdgeDir )void FreiDir( const HObject& Image, HObject* ImageEdgeAmp, HObject* ImageEdgeDir )static void HOperatorSet.FreiDir( HObject image, out HObject imageEdgeAmp, out HObject imageEdgeDir )def frei_dir( image: HObject ) -> Tuple[HObject, HObject]

Herror frei_dir( const Hobject Image, Hobject* ImageEdgeAmp, Hobject* ImageEdgeDir )

Herror T_frei_dir( const Hobject Image, Hobject* ImageEdgeAmp, Hobject* ImageEdgeDir )

HImage HImage::FreiDir( HImage* ImageEdgeDir ) const

HImage HImage.FreiDir( out HImage imageEdgeDir )

Description🔗

frei_dirFreiDir calculates an approximation of the first derivative of the image data and is used as an edge detector. The filter is based on the following filter masks:

\[\begin{eqnarray*} A &=& \begin{array}{rrr} 1 & \sqrt{2} & 1\\ 0 & 0 & 0\\ -1 & -\sqrt{2} & -1 \end{array}\\ B &=& \begin{array}{rrr} 1 & 0 & -1\\ \sqrt{2} & 0 & -\sqrt{2}\\ 1 & 0 & -1 \end{array} \end{eqnarray*}\]

The result image contains the maximum response of the masks \(A\) and \(B\). The edge directions are returned in ImageEdgeDirimageEdgeDirimage_edge_dir, and are stored in 2-degree steps, i.e., an edge direction of \(x\) degrees in mathematically positive sense and with respect to the horizontal axis is stored as \(x / 2\) in the edge direction image. Furthermore, the direction of the change of intensity is taken into account. Let \([E_{x},E_{y}]\) denote the image gradient. Then the following edge directions are returned as \(r/2\):

\[\begin{eqnarray*} \begin{array}{lcl} \mbox{intensity increase} & E_{x} / E_{y} & \\ &&\\ \mbox{edge direction $r$}\\ \mbox{from bottom to top} & 0 / + & 0\\ \mbox{from lower right to upper left} & - / + & ]0,90[\\ \mbox{from right to left} & - / 0 & 90 \\ \mbox{from upper right to lower left} & - / - & ]90,180[\\ \mbox{from top to bottom} & 0 / - & 180 \\ \mbox{from upper left to lower right} & + / - & ]180,270[\\ \mbox{from left to right} & + / 0 & 270\\ \mbox{from lower left to upper right} & + / + & ]270,360[ \end{array} \end{eqnarray*}\]

Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).

Attention🔗

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on domain level.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image(-array) → object (byte / int2 / uint2)HObject (byte / int2 / uint2)HImage (byte / int2 / uint2)HObject (byte / int2 / uint2)Hobject (byte / int2 / uint2)

Input image.

ImageEdgeAmpimageEdgeAmpimage_edge_amp (output_object) (multichannel-)image(-array) → object (byte / int2 / uint2)HObject (byte / int2 / uint2)HImage (byte / int2 / uint2)HObject (byte / int2 / uint2)Hobject * (byte / int2 / uint2)

Edge amplitude (gradient magnitude) image.

ImageEdgeDirimageEdgeDirimage_edge_dir (output_object) (multichannel-)image(-array) → object (direction)HObject (direction)HImage (direction)HObject (direction)Hobject * (direction)

Edge direction image.

Example🔗

(HDevelop)

read_image(Image,'fabrik')
frei_dir(Image,Frei_dirA,Frei_dirD)
threshold(Frei_dirA,Res,128,255)
(C)
read_image(&Image,"fabrik")\;
frei_dir(Image,&Frei_dirA,&Frei_dirD)\;
threshold(Frei_dirA,&Res,128,255)\;

Result🔗

frei_dirFreiDir always returns 2 (H_MSG_TRUE). If the input is empty the behavior can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

binomial_filterBinomialFilter, gauss_filterGaussFilter, sigma_imageSigmaImage, median_imageMedianImage, smooth_imageSmoothImage

Possible successors

hysteresis_thresholdHysteresisThreshold, thresholdThreshold, gray_skeletonGraySkeleton, nonmax_suppression_dirNonmaxSuppressionDir, close_edgesCloseEdges, close_edges_lengthCloseEdgesLength

Alternatives

edges_imageEdgesImage, sobel_dirSobelDir, robinson_dirRobinsonDir, prewitt_dirPrewittDir, kirsch_dirKirschDir

See also

bandpass_imageBandpassImage, laplace_of_gaussLaplaceOfGauss

Module🔗

Foundation