programlibs/Conv/demos/edges.xtl

Conv on one small picture: a square, two edge filters, ReLU and pooling, drawn. Run with "just demo-lib Conv edges".

source · imports cv: libs/Conv/src/Conv.xtl

r : Int

value · line 8

A 10 x 10 picture: a bright square on dark.

r ← (o̲ffsets 10) 'l̲eft t̲able o̲ffsets 10
Used in: x

cc : Int

value · line 9
cc ← (o̲ffsets 10) 'r̲ight t̲able o̲ffsets 10
Used in: x

x : Float

value · line 10
x ← 1 10 10 r̲eshape f̲loat (r > 2) ∧ (r < 7) ∧ (cc > 2) ∧ cc < 7

K : Float

value · line 12

Two filters: left-to-right brightening (a left edge), and top-to-bottom.

K ← 2 9 r̲eshape -1.0 0.0 1.0 -1.0 0.0 1.0 -1.0 0.0 1.0 -1.0 -1.0 -1.0 0.0 0.0 0.0 1.0 1.0 1.0
Used in: m

ᵘs̲hade : Num a => a -> Char

function · line 13
ᵘs̲hade ← { m → (1 + f̲loor 0 m̲ax 3 m̲in m) s̲elect " .:#" }

m : Float

value · line 16
m ← 0.0 m̲ax (K, 0.0 0.0) ᶜᵛc̲onv x