Module: Hornetseye
- Defined in:
- lib/multiarray.rb,
lib/multiarray/int.rb,
lib/multiarray/lut.rb,
lib/multiarray/rgb.rb,
lib/multiarray/rgb.rb,
lib/multiarray/bool.rb,
lib/multiarray/list.rb,
lib/multiarray/mask.rb,
lib/multiarray/node.rb,
lib/multiarray/field.rb,
lib/multiarray/float.rb,
lib/multiarray/index.rb,
lib/multiarray/store.rb,
lib/multiarray/inject.rb,
lib/multiarray/lambda.rb,
lib/multiarray/lookup.rb,
lib/multiarray/malloc.rb,
lib/multiarray/object.rb,
lib/multiarray/random.rb,
lib/multiarray/unmask.rb,
lib/multiarray/complex.rb,
lib/multiarray/complex.rb,
lib/multiarray/element.rb,
lib/multiarray/gcctype.rb,
lib/multiarray/methods.rb,
lib/multiarray/pointer.rb,
lib/multiarray/diagonal.rb,
lib/multiarray/gcccache.rb,
lib/multiarray/gccvalue.rb,
lib/multiarray/integral.rb,
lib/multiarray/sequence.rb,
lib/multiarray/variable.rb,
lib/multiarray/composite.rb,
lib/multiarray/histogram.rb,
lib/multiarray/shortcuts.rb,
lib/multiarray/components.rb,
lib/multiarray/gcccontext.rb,
lib/multiarray/multiarray.rb,
lib/multiarray/operations.rb,
lib/multiarray/elementwise.rb,
lib/multiarray/gccfunction.rb
Overview
Namespace of Hornetseye computer vision library
Defined Under Namespace
Modules: Methods, MultiArrayConstructor, MultiArrayConversion, ReaderConversion Classes: BOOL, COMPLEX_, Components, Composite, Diagonal, Element, ElementWise_, FLOAT_, Field_, GCCCache, GCCContext, GCCFunction, GCCType, GCCValue, Histogram, INDEX_, INT_, Inject, Integral, InternalComplex, Lambda, List, Lookup, Lut, Malloc, Mask, MultiArray, Node, OBJECT, Pointer_, RGB, RGB_, Random, Sequence, Store, Unmask, Variable
Constant Summary collapse
- SINGLE =
Boolean constant to use as a parameter for creating floating point classes
The value is
false
. false
- DOUBLE =
Boolean constant to use as a parameter for creating floating point classes
The value is
true
. true
- SFLOAT =
Single-precision floating-point number
FLOAT SINGLE
- DFLOAT =
Double-precision floating-point number
FLOAT DOUBLE
- SCOMPLEX =
Convenience shortcut for single-precision floating-point complex numbers
COMPLEX SFLOAT
- DCOMPLEX =
Convenience shortcut for double-precision floating-point complex numbers
COMPLEX DFLOAT
- BYTERGB =
24-bit unsigned RGB-triplet
RGB BYTE
- UBYTERGB =
24-bit signed RGB-triplet
RGB UBYTE
- SINTRGB =
48-bit unsigned RGB-triplet
RGB SINT
- USINTRGB =
48-bit signed RGB-triplet
RGB USINT
- INTRGB =
96-bit unsigned RGB-triplet
RGB INT
- UINTRGB =
96-bit signed RGB-triplet
RGB UINT
- LONGRGB =
192-bit unsigned RGB-triplet
RGB LONG
- ULONGRGB =
192-bit signed RGB-triplet
RGB ULONG
- SFLOATRGB =
single precision RGB-triplet
RGB SFLOAT
- DFLOATRGB =
double precision RGB-triplet
RGB DFLOAT
- UNSIGNED =
Boolean constant to use as a parameter for creating integer classes
The value is
false
. false
- SIGNED =
Boolean constant to use as a parameter for creating integer classes
The value is
true
. true
- BYTE =
8-bit signed integer
INT 8, SIGNED
- UBYTE =
8-bit unsigned integer
INT 8, UNSIGNED
- SINT =
16-bit signed integer
INT 16, SIGNED
- USINT =
16-bit unsigned integer
INT 16, UNSIGNED
- INT =
32-bit signed integer
INT 32, SIGNED
- UINT =
32-bit unsigned integer
INT 32, UNSIGNED
- LONG =
64-bit signed integer
INT 64, SIGNED
- ULONG =
64-bit unsigned integer
INT 64, UNSIGNED
Class Method Summary collapse
-
.BOOL(value) ⇒ BOOL
Shortcut for constructor.
-
.BYTE(value) ⇒ BYTE
Shortcut for constructor.
-
.BYTERGB(value) ⇒ BYTERGB
Shortcut for constructor.
-
.COMPLEX(element_type) ⇒ Class
Create a class deriving from
COMPLEX_
. -
.DCOMPLEX(value) ⇒ DCOMPLEX
Shortcut for constructor.
-
.DFLOAT(value) ⇒ DFLOAT
Shortcut for constructor.
-
.DFLOATRGB(value) ⇒ DFLOATRGB
Shortcut for constructor.
-
.ElementWise(operation, key, conversion = lambda { |t| t.send :identity }) ⇒ Class
Create a class deriving from
ElementWise_
. -
.finalise(*shape) { ... } ⇒ Object, Node
Method for performing a lazy computation and then forcing the result.
-
.FLOAT(double) ⇒ Class
Create a class deriving from
FLOAT_
. -
.INDEX(size) ⇒ Class
Instantiate the type of an array index.
-
.INT(arg, signed = nil) ⇒ Class, INT
Create a class deriving from
INT_
or instantiate anINT
object. -
.INTRGB(value) ⇒ INTRGB
Shortcut for constructor.
-
.lazy(*shape) { ... } ⇒ Object, Node
Method for performing computations in lazy mode resulting in a lazy expression.
-
.LONG(value) ⇒ LONG
Shortcut for constructor.
-
.LONGRGB(value) ⇒ LONGRGB
Shortcut for constructor.
- .MultiArray(typecode, dimension) ⇒ Object
-
.OBJECT(value) ⇒ OBJECT
Shortcut for constructor.
-
.Pointer(target) ⇒ Class
Create a class deriving from
Pointer_
. -
.RGB(arg, g = nil, b = nil) ⇒ Class, RGB
Create a class deriving from
RGB_
or instantiate anRGB
object. -
.SCOMPLEX(value) ⇒ SCOMPLEX
Shortcut for constructor.
-
.Sequence(element_type) ⇒ Class
Create a class to represent one-dimensional uniform arrays.
-
.SFLOAT(value) ⇒ SFLOAT
Shortcut for constructor.
-
.SFLOATRGB(value) ⇒ SFLOATRGB
Shortcut for constructor.
-
.SINT(value) ⇒ SINT
Shortcut for constructor.
-
.SINTRGB(value) ⇒ SINTRGB
Shortcut for constructor.
-
.sum(*shape) { ... } ⇒ Object, Node
Method for summing values.
-
.UBYTE(value) ⇒ UBYTE
Shortcut for constructor.
-
.UBYTERGB(value) ⇒ UBYTERGB
Shortcut for constructor.
-
.UINT(value) ⇒ UINT
Shortcut for constructor.
-
.UINTRGB(value) ⇒ UINTRGB
Shortcut for constructor.
-
.ULONG(value) ⇒ ULONG
Shortcut for constructor.
-
.ULONGRGB(value) ⇒ ULONGRGB
Shortcut for constructor.
-
.USINT(value) ⇒ USINT
Shortcut for constructor.
-
.USINTRGB(value) ⇒ USINTRGB
Shortcut for constructor.
Class Method Details
.BOOL(value) ⇒ BOOL
Shortcut for constructor
The method calls BOOL.new
.
148 149 150 |
# File 'lib/multiarray/bool.rb', line 148 def BOOL( value ) BOOL.new value end |
.BYTE(value) ⇒ BYTE
Shortcut for constructor
The method calls BYTE.new
.
350 351 352 |
# File 'lib/multiarray/int.rb', line 350 def BYTE( value ) BYTE.new value end |
.BYTERGB(value) ⇒ BYTERGB
Shortcut for constructor
The method calls BYTERGB.new
.
746 747 748 |
# File 'lib/multiarray/rgb.rb', line 746 def BYTERGB(value) BYTERGB.new value end |
.COMPLEX(element_type) ⇒ Class
Create a class deriving from COMPLEX_
Create a class deriving from COMPLEX_
. The parameter element_type
is assigned to the corresponding attribute of the resulting class.
1064 1065 1066 |
# File 'lib/multiarray/complex.rb', line 1064 def COMPLEX( element_type ) COMPLEX_.inherit element_type end |
.DCOMPLEX(value) ⇒ DCOMPLEX
Shortcut for constructor
The method calls DCOMPLEX.new
.
1098 1099 1100 |
# File 'lib/multiarray/complex.rb', line 1098 def DCOMPLEX(value) DCOMPLEX.new value end |
.DFLOAT(value) ⇒ DFLOAT
Shortcut for constructor
The method calls DFLOAT.new
.
278 279 280 |
# File 'lib/multiarray/float.rb', line 278 def DFLOAT( value ) DFLOAT.new value end |
.DFLOATRGB(value) ⇒ DFLOATRGB
Shortcut for constructor
The method calls DFLOATRGB.new
.
863 864 865 |
# File 'lib/multiarray/rgb.rb', line 863 def DFLOATRGB(value) DFLOATRGB.new value end |
.ElementWise(operation, key, conversion = lambda { |t| t.send :identity }) ⇒ Class
Create a class deriving from ElementWise_
230 231 232 233 234 235 236 |
# File 'lib/multiarray/elementwise.rb', line 230 def ElementWise( operation, key, conversion = lambda { |t| t.send :identity } ) retval = Class.new ElementWise_ retval.operation = operation retval.key = key retval.conversion = conversion retval end |
.finalise(*shape) { ... } ⇒ Object, Node
Method for performing a lazy computation and then forcing the result
attempts to infer the shape if not specified.
805 806 807 808 809 810 811 812 813 814 |
# File 'lib/multiarray.rb', line 805 def finalise( *shape, &action ) previous = Thread.current[ :lazy ] Thread.current[ :lazy ] = false begin retval = lazy *shape, &action retval.matched? ? retval.force : retval ensure Thread.current[ :lazy ] = previous end end |
.FLOAT(double) ⇒ Class
Create a class deriving from FLOAT_
Create a class deriving from FLOAT_
. The parameters double
is assigned to the corresponding attributes of the resulting class.
242 243 244 |
# File 'lib/multiarray/float.rb', line 242 def FLOAT(double) FLOAT_.inherit double end |
.INDEX(size) ⇒ Class
Instantiate the type of an array index
115 116 117 118 119 120 |
# File 'lib/multiarray/index.rb', line 115 def INDEX( size ) retval = Class.new INDEX_ size = INT.new(size) unless size.matched? retval.size = size retval end |
.INT(bits, signed) ⇒ Class .INT(value) ⇒ INT
Create a class deriving from INT_
or instantiate an INT
object
307 308 309 310 311 312 313 |
# File 'lib/multiarray/int.rb', line 307 def INT( arg, signed = nil ) if signed.nil? INT.new arg else INT_.inherit arg, signed end end |
.INTRGB(value) ⇒ INTRGB
Shortcut for constructor
The method calls INTRGB.new
.
798 799 800 |
# File 'lib/multiarray/rgb.rb', line 798 def INTRGB(value) INTRGB.new value end |
.lazy(*shape) { ... } ⇒ Object, Node
Method for performing computations in lazy mode resulting in a lazy expression
attempts to infer the shape if not specified.
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
# File 'lib/multiarray.rb', line 774 def lazy( *shape, &action ) previous = Thread.current[ :lazy ] Thread.current[ :lazy ] = true begin = shape.last.is_a?( Hash ) ? shape.pop : {} arity = [ :arity ] || [ action.arity, shape.size ].max if arity <= 0 action.call else index = Variable.new shape.empty? ? Hornetseye::INDEX( nil ) : Hornetseye::INDEX( shape.pop ) term = lazy *( shape + [ :arity => arity - 1 ] ) do |*args| action.call *( args + [ index ] ) end term = Node.match(term).new term unless term.matched? Lambda.new index, term.sexp end ensure Thread.current[ :lazy ] = previous end end |
.LONG(value) ⇒ LONG
Shortcut for constructor
The method calls LONG.new
.
415 416 417 |
# File 'lib/multiarray/int.rb', line 415 def LONG( value ) LONG.new value end |
.LONGRGB(value) ⇒ LONGRGB
Shortcut for constructor
The method calls LONGRGB.new
.
824 825 826 |
# File 'lib/multiarray/rgb.rb', line 824 def LONGRGB(value) LONGRGB.new value end |
.MultiArray(typecode, dimension) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/multiarray/multiarray.rb', line 99 def MultiArray(typecode, dimension) if dimension > 0 Field_.inherit typecode.typecode, typecode.dimension + dimension else Hornetseye::Pointer typecode end end |
.OBJECT(value) ⇒ OBJECT
Shortcut for constructor
The method calls OBJECT.new
.
165 166 167 |
# File 'lib/multiarray/object.rb', line 165 def OBJECT( value ) OBJECT.new value end |
.Pointer(target) ⇒ Class
Create a class deriving from Pointer_
Create a class deriving from Pointer_
. The parameter target
is assigned to the corresponding attribute of the resulting class.
278 279 280 281 282 |
# File 'lib/multiarray/pointer.rb', line 278 def Pointer( target ) p = Class.new Pointer_ p.target = target p end |
.RGB(element_type) ⇒ Class .RGB(r, g, b) ⇒ RGB
Create a class deriving from RGB_
or instantiate an RGB
object
697 698 699 700 701 702 703 |
# File 'lib/multiarray/rgb.rb', line 697 def RGB( arg, g = nil, b = nil ) if g.nil? and b.nil? RGB_.inherit arg else RGB.new arg, g, b end end |
.SCOMPLEX(value) ⇒ SCOMPLEX
Shortcut for constructor
The method calls SCOMPLEX.new
.
1085 1086 1087 |
# File 'lib/multiarray/complex.rb', line 1085 def SCOMPLEX(value) SCOMPLEX.new value end |
.Sequence(element_type) ⇒ Class
Create a class to represent one-dimensional uniform arrays
82 83 84 |
# File 'lib/multiarray/sequence.rb', line 82 def Sequence(element_type) Hornetseye::MultiArray element_type, 1 end |
.SFLOAT(value) ⇒ SFLOAT
Shortcut for constructor
The method calls SFLOAT.new
.
263 264 265 |
# File 'lib/multiarray/float.rb', line 263 def SFLOAT( value ) SFLOAT.new value end |
.SFLOATRGB(value) ⇒ SFLOATRGB
Shortcut for constructor
The method calls SFLOATRGB.new
.
850 851 852 |
# File 'lib/multiarray/rgb.rb', line 850 def SFLOATRGB(value) SFLOATRGB.new value end |
.SINT(value) ⇒ SINT
Shortcut for constructor
The method calls SINT.new
.
376 377 378 |
# File 'lib/multiarray/int.rb', line 376 def SINT( value ) SINT.new value end |
.SINTRGB(value) ⇒ SINTRGB
Shortcut for constructor
The method calls SINTRGB.new
.
772 773 774 |
# File 'lib/multiarray/rgb.rb', line 772 def SINTRGB(value) SINTRGB.new value end |
.sum(*shape) { ... } ⇒ Object, Node
Method for summing values
attempts to infer the shape if not specified.
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/multiarray.rb', line 825 def sum( *shape, &action ) = shape.last.is_a?( Hash ) ? shape.pop : {} arity = [ :arity ] || [ action.arity, shape.size ].max if arity <= 0 term = action.call term.matched? ? term.to_type(term.typecode.maxint) : term else index = Variable.new shape.empty? ? Hornetseye::INDEX( nil ) : Hornetseye::INDEX( shape.pop ) term = sum *( shape + [ :arity => arity - 1 ] ) do |*args| action.call *( args + [ index ] ) end var1 = Variable.new term.typecode var2 = Variable.new term.typecode Inject.new( term, index, nil, var1 + var2, var1, var2 ).force end end |
.UBYTE(value) ⇒ UBYTE
Shortcut for constructor
The method calls UBYTE.new
.
363 364 365 |
# File 'lib/multiarray/int.rb', line 363 def UBYTE( value ) UBYTE.new value end |
.UBYTERGB(value) ⇒ UBYTERGB
Shortcut for constructor
The method calls UBYTERGB.new
.
759 760 761 |
# File 'lib/multiarray/rgb.rb', line 759 def UBYTERGB(value) UBYTERGB.new value end |
.UINT(value) ⇒ UINT
Shortcut for constructor
The method calls UINT.new
.
402 403 404 |
# File 'lib/multiarray/int.rb', line 402 def UINT( value ) UINT.new value end |
.UINTRGB(value) ⇒ UINTRGB
Shortcut for constructor
The method calls UINTRGB.new
.
811 812 813 |
# File 'lib/multiarray/rgb.rb', line 811 def UINTRGB(value) UINTRGB.new value end |
.ULONG(value) ⇒ ULONG
Shortcut for constructor
The method calls ULONG.new
.
428 429 430 |
# File 'lib/multiarray/int.rb', line 428 def ULONG( value ) ULONG.new value end |
.ULONGRGB(value) ⇒ ULONGRGB
Shortcut for constructor
The method calls ULONGRGB.new
.
837 838 839 |
# File 'lib/multiarray/rgb.rb', line 837 def ULONGRGB(value) ULONGRGB.new value end |