scaleex-scale.html
doubleCode_samples.html
mergeex-merge.html
sumex-sum.html
dxex-dx.html
wiring functionsex-msfl.html
histoex-histo.html
RLEex-rle.html
convol
higher order
actorex-fmap.html
 

#include "convol.cph"


stream i1:unsigned<12> dc from "sample.txt";

stream i2:signed<16> dc from "image.txt";


stream r1:unsigned<12> dc to "result1.txt";

stream r2:signed<16> dc to "result2.txt";


net r1 = conv115 ([2,3,6,3,2], 4, 0) i1;


net r2 = cconv233 ([[0,-1,0],    

                    [-1,4,-1],

                    [0,-1,0]], 0, 0) i2;



This small program illustrates the use of the CAPH standard library to implement « classical» 1D and 2D signal processing operations.


The conv115 actor (defined in « convol.cph »)  applies a 1x5 smoothing convolution kernel to a 1D signal represented  as  list of unsigned 12-bit integers. The kernel is specified has the first parameter. The second parameter is the scaling factor (as the power of two) and the third parameter is the padding value. If the stream on input i1 is: 

    < x1 x2 ... xn >

then the stream on output r1 will be :

    < y1 y2 ... yn >

where yi = v                                                                     for 1 ≤ i < 5

           yi = (k0.xi-4 + k1.xi-3 + k2.xi-2 + k3.xi-1 + k4.xi )/2s       for 5 ≤ i ≤ n

and v=0, k[0..4]=[2,3,6,2,2] and s=4 here.

The cconv233 actor, also defined in « convol.cph» applies a 3x3 Laplacian centered convolution kernel to an MxN image here represented as a list of lists of signed 16-bit integers. The kernel is specified has the first parameter as a 2D-array. The second parameter is the scaling factor (as the power of two) and the third parameter is the padding value.

If the stream on input i2 is: 

    < < x11 x12 ... x1N > < x21 x22 ... x2N > ... < xM1 xM2 ... xMN > >

then the stream on output r2 will be :

    < < y11 y12 ... y1N > < y21 y22 ... y2N > ... < yM1 yM2 ... y2N > >

where yij = v                                                                                                                                                for i=1, i=M, j=1 or j=N

           yij = (k0,0.xi-1,j-1+k0,1.xi-1,j+k0,2.xi-1,j+1+k1,0.xi,j-1+k1,1.xi,j+k1,2.xi,j+1+k2,0.xi+1,j-1+k2,1.xi+1,j+k2,2.xi+1,j+1)/2s       for 2≤i≤ M-1 and 2≤j≤N-1

and v=0, k[0..2][0..2]=[[0,-1,0],[-1,4,-1],[0,-1,0]] and s=0 here.