Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
out_magnitudes
Pointer to ouput image for absolute gradient
out_angles
Pointer to ouput image for gradient angles in the range
Returns
The cpl error code if any occurred
Introduction:
This function computes the absolute gradient field of the input image, and the corresponding orientation field. There are the following constraints:
The pointers to the output image pointers must not be NULL.
The input can be integer, float or double.
If the input is of type integer, then values of type double will be produced as output, otherwise the created output images are of the same type as the input image.
On failure, NULL pointers are returned.
Error Handling
The following error codes can be set and returned:
CPL_ERROR_NULL_INPUT: any of the input or output pointers is NULL
CPL_ERROR_INVALID_TYPE: input is neither of type CPL_TYPE_INT, CPL_TYPE_FLOAT, nor of type CPL_TYPE_DOUBLE
Image containing local angle values (FITS convention)
window_xxyy
Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
periodic_factor
Divisor for the periodicity of
out_norm
(Optional output) the gradient's norm
Returns
Mean angle inside range of , -1 in the case of error
Principle:
Consider a local angle , a local weight and a periodic factor . Then the mean angle is determined by:
It does not always make sense to compute a mean angle in the range , for example a line crossing an image has an orientation but the orientation has no sign. In this case, only angles in the range are interesting. Therefore, the periodic factor is adjustable. For example, a periodic factor of causes opposite angles to fall together in the complex plane before summing, and thus to be considered the same. The final division by scales the angle back to the range . The following values for periodic_factor are of specific interest:
periodic_factor
Example Purpose
1
Uni-directional (e.g. global) gradients
2
Lines and rectangular apertures
3
Equilateral triangles
4
Square apertures, crossing spikes of secondary mirror
holder
6
Honeycombs
Constraints:
The input images must be of the same cpl_type and size.
The cpl_type of the input images must be one of CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE.
Bad Pixel Handling:
Pixels which are bad in either magnitudes or angles are ignored during computation.
Error Handling:
The following error codes can be set:
CPL_ERROR_NULL_INPUT: magnitudes or angles is NULL
CPL_ERROR_TYPE_MISMATCH: magnitudes and angles are not of the same type
CPL_ERROR_ACCESS_OUT_OF_RANGE: window coordinates are outside the images
CPL_ERROR_INVALID_TYPE: magnitudes and angles are neither of type CPL_TYPE_FLOAT nor of type CPL_TYPE_DOUBLE
CPL_ERROR_INCOMPATIBLE_INPUT: magnitudes and angles don't have the same size
Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
periodic_factor
Divisor for the periodicity of
radius_sigma
Sigma of the gaussian used for the lowpass
mean_magnitudes
(Optional output) magnitudes of lowpassed gradients
mean_angles
(Optional output) angles of lowpassed gradients
Returns
CPL error code
Principle:
The formula to compute a mean gradient from a region of gradients from function clipm_priv_image_compute_mean_angle() is used, but with the extension that the input gradients are weighted with a Gaussian bell kurve with sigma radius_sigma.
Constraints:
The input images must be of the same cpl_type and size.
The cpl_type of the input images must be one of CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE.
Bad Pixel Handling:
Pixels which are bad in either magnitudes or angles are skipped during computation.
Error Handling:
The following error codes can be set:
CPL_ERROR_NULL_INPUT: magnitudes or angles is NULL
CPL_ERROR_TYPE_MISMATCH: magnitudes and angles are not of the same type
CPL_ERROR_ACCESS_OUT_OF_RANGE: window coordinates are outside the images
CPL_ERROR_INVALID_TYPE: magnitudes and angles are neither of type CPL_TYPE_FLOAT nor of type CPL_TYPE_DOUBLE
CPL_ERROR_INCOMPATIBLE_INPUT: magnitudes and angles don't have the same size
Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
Returns
Horizontal gradient image, NULL in the case of error
Principle:
A sobel operator is an edge detecting convolution kernel, relatively insensitive to noise. The horizontal one is (here normed by one eighth):
The input can be integer, float or double.
If the input is of type integer, then values of type double will be produced as output.
Bad Pixel Handling:
Bad pixels in the input image will contaminate their neighbours.
Specifying no window, or a window touching the image border, will result in bad pixels at the output border.
Error Handling:
The following error codes can be set:
CPL_ERROR_NULL_INPUT: if input is NULL
CPL_ERROR_ACCESS_OUT_OF_RANGE: a window coordinate exceeds the image range
CPL_ERROR_INVALID_TYPE: input is neither of type CPL_TYPE_INT, CPL_TYPE_FLOAT nor CPL_TYPE_DOUBLE
Note
In the worst case, a sobel operator without a pre-factor can produce a value 8 times higher than the maximum, and can by this way cause a range violation (resulting in an infinite number). For this reason the pre-factor is used here. But be aware, that this pre-factor causes an increased quantization error when applied to integer numbers.
Coordinate buffer of the form {xa, xb, ya, yb}, can be NULL, minimum/maximum order is irrelevant
Returns
Vertical gradient image, NULL in the case of error
Principle:
A sobel operator is an edge detecting convolution kernel, relatively insensitive to noise. The vertical one is (here normed by one eighth):
The input can be integer, float or double.
If the input is of type integer, then values of type double will be produced as output.
Bad Pixel Handling:
Bad pixels in the input image will contaminate their neighbours.
Specifying no window, or a window touching the image border, will result in bad pixels at the output border.
Error Handling
The following error codes can be set:
CPL_ERROR_NULL_INPUT: if input is NULL
CPL_ERROR_ACCESS_OUT_OF_RANGE: a window coordinate exceeds the image range
CPL_ERROR_INVALID_TYPE: input is neither of type CPL_TYPE_INT, CPL_TYPE_FLOAT nor CPL_TYPE_DOUBLE
Note
In the worst case, a sobel operator without a pre-factor can produce a value 8 times higher than the maximum, and can by this way cause a range violation (resulting in an infinite number). For this reason the pre-factor is used here. But be aware, that this pre-factor causes an increased quantization error when applied to integer numbers.