cz.cuni.jagrlib.testing
Class SampleRasterSearch

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.testing.SampleRasterSearch
All Implemented Interfaces:
Breakable, Property, RasterSearch, Template

public class SampleRasterSearch
extends Piece
implements RasterSearch

Sample raster-search implementation. Uses only luminance search, one pixel pisition accuracy and RMSE.

See Also:
SampleRasterSearch.java

Field Summary
protected  int actBandMask
          Actual band mask.
protected  double actMaxO
          Actual maximum value of additive coefficient o.
protected  double actMaxS
          Actual maximum value of multiplication coefficient s.
protected  int actMaxX
          Actual maximum X coordinate of a search (can be 0 for unbounded search).
protected  int actMaxY
          Actual maximum Y coordinate of a search (can be 0 for unbounded search).
protected  int actMetrics
          Actual metrics.
protected  double actMinO
          Actual minimum value of additive coefficient o.
protected  double actMinS
          Actual minimum value of multiplication coefficient s.
protected  int actMinX
          Actual minimum X coordinate of a search.
protected  int actMinY
          Actual minimum Y coordinate of a search.
protected  int actOriMask
          Actual orientation mask.
protected  double actPrecision
          Actual position accuracy.
protected  int actRelX
          Actual maximum X displacement for relative search (should be 0 for absolute search).
protected  int actRelY
          Actual maximum Y displacement for relative search (can be 0 for absolute search).
protected static java.lang.String CATEGORY
          Object category.
protected  HDRImage[] refs
          Reference pictures.
static RegPiece reg
          Static registration instance for this class.
protected static java.lang.String TEMPLATE_NAME
          Object template identifier.
static java.lang.String USE_GRAY
           
protected  boolean useGray
          Use only gray (luminance) component of the images?
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.RasterSearch
ERR_MAE, ERR_RMSE, MAX_REFERENCE, ORI_0123, ORI_0213, ORI_1032, ORI_1302, ORI_2031, ORI_2301, ORI_3120, ORI_3210, ORI_FAIL, ORI_INV
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
SampleRasterSearch()
           
 
Method Summary
 int findBestRectangle(RasterGraphics f, int x, int y, int width, int height, int ref, double[] result)
          Searches for the most similar rectangle in one of predefined reference images.
 java.lang.Object get(java.lang.String key)
          Gets the given property.
 void set(java.lang.String key, java.lang.Object value)
          Sets the given property.
 void setReferencePicture(RasterGraphics g, int id, double scale, int oriMask, boolean pixelTransform)
          Sets reference image.
 void setSearchParameters(int oriMask, int bandMask, int metrics, double precision, int absMinX, int absMaxX, int absMinY, int absMaxY, int relX, int relY, double minMul, double maxMul, double minAdd, double maxAdd)
          Sets parameters for subsequent searches.
static int setTemplate(Template t, int ord)
          General-purpose registration routine.
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit
 

Field Detail

useGray

protected boolean useGray
Use only gray (luminance) component of the images?


actOriMask

protected int actOriMask
Actual orientation mask.


actBandMask

protected int actBandMask
Actual band mask.


actMetrics

protected int actMetrics
Actual metrics.


actPrecision

protected double actPrecision
Actual position accuracy.


actMinX

protected int actMinX
Actual minimum X coordinate of a search.


actMaxX

protected int actMaxX
Actual maximum X coordinate of a search (can be 0 for unbounded search).


actMinY

protected int actMinY
Actual minimum Y coordinate of a search.


actMaxY

protected int actMaxY
Actual maximum Y coordinate of a search (can be 0 for unbounded search).


actRelX

protected int actRelX
Actual maximum X displacement for relative search (should be 0 for absolute search).


actRelY

protected int actRelY
Actual maximum Y displacement for relative search (can be 0 for absolute search).


actMinS

protected double actMinS
Actual minimum value of multiplication coefficient s. Must be set to 1.0 if no pixel transform is allowed).


actMaxS

protected double actMaxS
Actual maximum value of multiplication coefficient s. Must be set to 1.0 if no pixel transform is allowed).


actMinO

protected double actMinO
Actual minimum value of additive coefficient o.


actMaxO

protected double actMaxO
Actual maximum value of additive coefficient o.


refs

protected HDRImage[] refs
Reference pictures.


USE_GRAY

public static final java.lang.String USE_GRAY
See Also:
Constant Field Values

TEMPLATE_NAME

protected static final java.lang.String TEMPLATE_NAME
Object template identifier.

See Also:
Constant Field Values

CATEGORY

protected static final java.lang.String CATEGORY
Object category.

See Also:
Constant Field Values

reg

public static final RegPiece reg
Static registration instance for this class. Automatically initialized in class-loading time.

Constructor Detail

SampleRasterSearch

public SampleRasterSearch()
Method Detail

setReferencePicture

public void setReferencePicture(RasterGraphics g,
                                int id,
                                double scale,
                                int oriMask,
                                boolean pixelTransform)
Sets reference image. Reference images have to be set before you can search in them..

Specified by:
setReferencePicture in interface RasterSearch
Parameters:
g - Read-only raster image (can be null to reset the slot).
id - Reference image identifier (0, 1, .. RasterSearch.MAX_REFERENCE-1).
scale - Scale to be used in precomputing.
oriMask - Mask of orientations used in future search commands (non-mandatory, use 0 if not known).
pixelTransform - Will a linear pixel transform be used?
See Also:
RasterSearch.ORI_0123

setSearchParameters

public void setSearchParameters(int oriMask,
                                int bandMask,
                                int metrics,
                                double precision,
                                int absMinX,
                                int absMaxX,
                                int absMinY,
                                int absMaxY,
                                int relX,
                                int relY,
                                double minMul,
                                double maxMul,
                                double minAdd,
                                double maxAdd)
Sets parameters for subsequent searches.

Specified by:
setSearchParameters in interface RasterSearch
Parameters:
oriMask - Mask of valid orientations to search (1 << RasterSearch.ORI_0123, ..).
bandMask - Mask of searched image bands (Red .. 1, Green .. 2, Blue .. 4, ..).
metrics - One of {RasterSearch.ERR_MAE, RasterSearch.ERR_RMSE}.
precision - Sub-pixel precision of result coordinates (should be power of 1/2).
absMinX - Lower bound for X-coordinate of absolute search.
absMaxX - Upper bound for X-coordinate of absolute search (can be 0 for unbounded search).
absMinY - Lower bound for Y-coordinate of absolute search.
absMaxY - Upper bound for Y-coordinate of absolute search (can be 0 for unbounded search).
relX - X-amplitude of relative search (must be 0 for absolute search).
relY - Y-amplitude of relative search.
minMul - Minimum pixel-value multiplier (should be 1 if no multiplication is allowed).
maxMul - Maximum pixel-value multiplier (should be 1 if no multiplication is allowed).
minAdd - Minimum additive coefficient (should be 0 if no addition is allowed).
maxAdd - Maximum additive coefficient (should be 0 if no addition is allowed).

findBestRectangle

public int findBestRectangle(RasterGraphics f,
                             int x,
                             int y,
                             int width,
                             int height,
                             int ref,
                             double[] result)
Searches for the most similar rectangle in one of predefined reference images.

Specified by:
findBestRectangle in interface RasterSearch
Parameters:
f - Raster image containing the sought rectangle.
x - Origin of the sought rectangle.
y - Origin of the sought rectangle.
width - Width of the sought rectangle.
height - Height of the sought rectangle.
ref - Reference image to be scanned.
result - Pre-allocated result array double[5], will hold coordinates, coefficients and error measure [x,y,mul,add,err].
Returns:
Orientation of the best fit (or RasterSearch.ORI_FAIL in case of failure).

set

public void set(java.lang.String key,
                java.lang.Object value)
Sets the given property.

Specified by:
set in interface Property
Overrides:
set in class DefaultProperty
Parameters:
key - Key string.
value - The new value.
See Also:
Property.commit()

get

public java.lang.Object get(java.lang.String key)
Gets the given property.

Specified by:
get in interface Property
Overrides:
get in class DefaultProperty
Parameters:
key - Key string.
Returns:
The actual value or null.

setTemplate

public static int setTemplate(Template t,
                              int ord)
General-purpose registration routine. Sets all plugs, strings, etc. to the given Template.