Herror ::prewitt_dir (
    Hobject Image,
    Hobject *ImageEdgeAmp,
    Hobject *ImageEdgeDir
)
HImage HImage::PrewittDir (
    HImage *ImageEdgeDir
) const
HImageArray HImageArray::PrewittDir (
    HImageArray *ImageEdgeDir
) const

Detect edges (amplitude and direction) using the Prewitt operator.

::prewitt_dir 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:

  A =
        1       1       1
        0       0       0
       -1      -1      -1

  B =
        1       0      -1
        1       0      -1
        1       0      -1  
The result image contains the maximum response of the masks A and B. The edge directions are returned in ImageEdgeDir, and are stored in 2-degree steps, i.e., an edge direction of x degrees 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 [Ex,Ey] denote the image gradient. Then the following edge directions are returned as r/2:
intensity increase                     Ex / Ey        edge direction r

from bottom to top                      0 / +         0
from lower right to upper left          + / -         ]0,90[
from right to left                      + / 0         90 
from upper right to lower left          + / +         ]90,180[
from top to bottom                      0 / +         180 
from upper left to lower right          - / +         ]180,270[
from left to right                      + / 0         270
from lower left to upper right          - / -         ]270,360[.
Points with edge amplitude 0 are assigned the edge direction 255 (undefined direction).


Parameters

Image (input_object)
(multichannel-)image(-array) -> Hobject: HImage(Array) ( byte )
Input image.

ImageEdgeAmp (output_object)
(multichannel-)image(-array) -> Hobject * : HImage(Array) ( byte )
Edge amplitude (gradient magnitude) image.

ImageEdgeDir (output_object)
(multichannel-)image(-array) -> Hobject * : HImage(Array) ( direction )
Edge direction image.


Example
read_image(&Image,"fabrik");
prewitt_dir(Image,&PrewittA,&PrewittD);
threshold(PrewittA,&Edges,128,255);

Result

::prewitt_dir always returns H_MSG_TRUE. If the input is empty the behaviour can be set via ::set_system('no_object_result',<Result>). If necessary, an exception handling is raised.


Possible Predecessors

::gauss_image, ::sigma_image, ::median_image, ::smooth_image


Possible Successors

::hysteresis_threshold, ::threshold, ::gray_skeleton, ::nonmax_suppression_dir, ::close_edges, ::close_edges_length


Alternatives

::edges_image, ::sobel_dir, ::robinson_dir, ::frei_dir, ::kirsch_dir


See also

::bandpass_image, ::laplace_of_gauss


Module

Image filters



Copyright © 1996-2002 MVTec Software GmbH