1 module rip.dsp.transforms.hadamard; 2 3 private 4 { 5 import std.math; 6 7 import rip.processing.filters.linear; 8 9 static float SQ2 = cast(float) SQRT2; 10 } 11 12 13 class Hadamard2 : LinearFilter 14 { 15 this() 16 { 17 apertureWidth = 2; 18 apertureHeight = 2; 19 apertureDivider = 1.0 / SQ2; 20 apertureOffset = 0.0f; 21 flattenKernel = flatten( 22 [ 23 [ 1.0f, 1.0f ], 24 [ 1.0f, -1.0f ], 25 ] 26 ); 27 } 28 } 29 30 31 class Hadamard4: LinearFilter 32 { 33 this() 34 { 35 apertureWidth = 4; 36 apertureHeight = 4; 37 apertureDivider = 0.5f; 38 apertureOffset = 0.0f; 39 flattenKernel = flatten( 40 [ 41 [ 1.0f, 1.0f, 1.0f, 1.0f ], 42 [ 1.0f, -1.0f, 1.0f -1.0f ], 43 [ 1.0f, 1.0f, -1.0f, -1.0f ], 44 [ 1.0f, -1.0f, -1.0f, 1.0f ], 45 ] 46 ); 47 } 48 } 49 50 51 class Hadamard8 : LinearFilter 52 { 53 this() 54 { 55 apertureWidth = 8; 56 apertureHeight = 8; 57 apertureDivider = 1.0f / SQ2; 58 apertureOffset = 0.0f; 59 flattenKernel = flatten( 60 [ 61 [ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f ], 62 [ 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f ], 63 [ 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f ], 64 [ 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f ], 65 [ 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f ], 66 [ 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f ], 67 [ 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f ], 68 [ 1.0f, -1.0f , -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f ], 69 ] 70 ); 71 } 72 }