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

actor dx

  in (i:unsigned<8> dc)

  out (o:unsigned<8> dc)

var state: {WaitImg, WaitLine, InLine} = WaitImg

var z: unsigned<8> -- previous pixel

rules

| (state:WaitImg,  i:’<) -> (state:WaitLine, o:’<)

| (state:WaitLine, i:’>) -> (state:WaitImg, o:’>)

| (state:WaitLine, i:’<) -> (state:InLine, z:’0)

| (state:InLine, i:’v)   -> (o:’v-z, z:’v)

| (state:InLine, i:’>)   -> (state:WaitLine, o:’>)

;

This actor computes the horizontal derivative of images, encoded as structured streams of pixels. For example, if the stream on input i is : 

    < < 1 2 3 > < 4 6 8 > < 10 14 22 >... >

then the stream on output o will be :

    < < 0 1 1 > < 0 2 2 > < 0 4 8 >... >

For this, it uses pattern matching on the input to detect the start and end of images and lines and two local variables :

  1. a variable state, indicating whether the actor is waiting for a new image, waiting for a new line in a image of processing a line

  2. a variable z memorizing the previous pixel value for computing the difference with the current pixel value (v)