1 module rip.processing.filters.robinson; 2 3 private 4 { 5 import rip.processing.filters.directions; 6 import rip.processing.filters.linear; 7 } 8 9 10 class RobinsonOperator : LinearFilter 11 { 12 this(CardinalDirection direction) 13 { 14 apertureWidth = 3; 15 apertureHeight = 3; 16 apertureDivider = 1.0f; 17 apertureOffset = 0.0f; 18 19 final switch (direction) with (CardinalDirection) 20 { 21 case NORTH: 22 flattenKernel = flatten( 23 [ 24 [ -1.0f, 0.0f, 1.0f ], 25 [ -2.0f, 0.0f, 2.0f ], 26 [ -1.0f, 0.0f, 1.0f ], 27 ] 28 ); 29 break; 30 31 case NORTH_WEST: 32 flattenKernel = flatten( 33 [ 34 [ 0.0f, 1.0f, 2.0f ], 35 [ -1.0f, 0.0f, 1.0f ], 36 [ -2.0f, -1.0f, 0.0f ], 37 ] 38 ); 39 break; 40 41 case WEST: 42 flattenKernel = flatten( 43 [ 44 [ 1.0f, 2.0f, 1.0f ], 45 [ 0.0f, 0.0f, 0.0f ], 46 [ -1.0f, -2.0f, -1.0f ], 47 ] 48 ); 49 break; 50 51 case SOUTH_WEST: 52 flattenKernel = flatten( 53 [ 54 [ 2.0f, 1.0f, 0.0f ], 55 [ 1.0f, 0.0f, -1.0f ], 56 [ 0.0f, -1.0f, -2.0f ], 57 ] 58 ); 59 break; 60 61 case SOUTH: 62 flattenKernel = flatten( 63 [ 64 [ 1.0f, 0.0f, -1.0f ], 65 [ 2.0f, 0.0f, -2.0f ], 66 [ 1.0f, 0.0f, -1.0f ], 67 ] 68 ); 69 break; 70 71 case SOUTH_EAST: 72 flattenKernel = flatten( 73 [ 74 [ 0.0f, -1.0f, -2.0f ], 75 [ 1.0f, 0.0f, -1.0f ], 76 [ 2.0f, 1.0f, 0.0f ], 77 ] 78 ); 79 break; 80 81 case EAST: 82 flattenKernel = flatten( 83 [ 84 [ -1.0f, -2.0f, -1.0f ], 85 [ 0.0f, 0.0f, 0.0f ], 86 [ 1.0f, 2.0f, 1.0f ], 87 ] 88 ); 89 break; 90 91 case NORTH_EAST: 92 flattenKernel = flatten( 93 [ 94 [ -2.0f, -1.0f, 0.0f ], 95 [ -1.0f, 0.0f, 1.0f ], 96 [ 0.0f, 1.0f, 2.0f ], 97 ] 98 ); 99 break; 100 } 101 } 102 }