VCLib Documentation  6.12.2

Convolutions

Functions

I32 ff3 (image *a, image *b, I32 c[3][3], I32 sh)
  3×3 Convolution Filter at an Image. More...
 
I32 ff5 (image *a, image *b, I32 c[5][5], I32 sh)
  5×5 Convolution Filter at an Image. More...
 
I32 ff5y (image *a, image *b, I32 *h, I32 *v, I32 sh)
  5×5 Convolution Filter with Horizontal/Vertical Separation. More...
 
I32 ff7y (image *a, image *b, I32 *h, I32 *v, I32 sh)
  7×7 Convolution Filter with Horizontal/Vertical Separation. More...
 

Detailed Description

Function Documentation

◆ ff3()

I32 ff3 ( image a,
image b,
I32  c[3][3],
I32  sh 
)

The function makes it possible to calculate 3×3 filter operations of the image variable a. In contrast to imgf(), this is always a convolution with a 3×3 mask. The two-dimensional array c[3][3] contains the coefficients for the convolution. Mask:

c[0][0]c[0][1]c[0][2]
c[1][0]c[1][1]c[2][2]
c[2][0]c[2][1]c[3][2]

The convolution with the mask is executed, the magnitude is calculated, and the result is shifted sh bits. sh=0 means no shift, sh=1 means multiply by 2, sh=-1 is equivalent to dividing by 2, etc.

filter_3x3_target.png

Note that the output pixel position is equal to the top left pixel position of the 3×3 matrix. The advantage of that positioning is the ability to use the input image as the output image. Also note that the last two columns and the last two rows of the image contain meaningless data.

Parameters
aSource Image.
bDestination Image.
cThe Filter Kernel.
shShift Value.
Memory Consumption
None.
See also
imgf(), ff5(), robert().
Return values
ERR_TYPEif a or b Image is no Grey Image.
ERR_NONEon Success

◆ ff5()

I32 ff5 ( image a,
image b,
I32  c[5][5],
I32  sh 
)

The function performs the 5×5 filter operation of image variable a with arbitrary mask c[5][5]. The result is stored in image b. The two-dimensional array c[5][5] contains the coefficients for the convolution mask. Mask:

c[0][0]c[0][1]c[0][2]c[0][3]c[0][4]
c[1][0]c[1][1]c[1][2]c[1][3]c[1][4]
c[2][0]c[2][1]c[2][2]c[2][3]c[2][4]
c[3][0]c[3][1]c[3][2]c[3][3]c[3][4]
c[4][0]c[4][1]c[4][2]c[4][3]c[4][4]

The convolution with the mask is executed, the magnitude is calculated, and the result is shifted sh bits. sh=0 means no shift, sh=1 means multiply by 2, sh=-1 is equivalent to dividing by 2, etc.

Memory Consumption
None.
See also
ff3(), ff5y(), imgf(), robert().

◆ ff5y()

I32 ff5y ( image a,
image b,
I32 h,
I32 v,
I32  sh 
)

The function performs a 5×5 filter operation of image variable a. The filter consists of a 1×5 and a 5×1 mask which are executed in sequence. The horizontal 5×1 mask is specified with array h[5], the vertical 1×5 mask is specified with array v[5]. The result of the operation will be stored in image b.

Horizontal mask:

h[0]h[1]h[2]h[3]h[4]

Vertical mask:

v[0]
v[1]
v[2]
v[3]
v[4]

The convolution with both masks is executed, the magnitude is calculated, and the result is shifted sh bits. sh=0 means no shift, sh=1 means multiply by 2, sh=-1 is equivalent to dividing by 2, etc.

Memory Consumption
20*(( b->dx)/2 + 1) Bytes.
See also
ff3(), ff5(), imgf(), robert().
Return values
ERR_TYPEif a or b Image is no Grey Image.
ERR_NONEon Success.

◆ ff7y()

I32 ff7y ( image a,
image b,
I32 h,
I32 v,
I32  sh 
)

The function performs a 7×7 filter operation of image variable a. The filter consists of a 1×7 and a 7×1 mask which are executed in sequence. The horizontal 7×1 mask is specified with array h[7], the vertical 1×7 mask is specified with array v[7]. The result of the operation will be stored in image b.

Horizontal mask:

h[0]h[1]h[2]h[3]h[4]h[5]h[6]

Vertical mask:

v[0]
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]

The convolution with both masks is executed, the magnitude is calculated, and the result is shifted sh bits. sh=0 means no shift, sh=1 means multiply by 2, sh=-1 is equivalent to dividing by 2, etc.

Memory Consumption
?? Bytes.
See also
ff3(), ff5(), f5hf(), f5vf(), imgf(), robert().
Return values
ERR_TYPEif src or dst Image is no Grey Image.
ERR_NONEon Success.