cz.cuni.jagrlib.iface
Interface RasterSearch

All Superinterfaces:
Property
All Known Implementing Classes:
SampleRasterSearch

public interface RasterSearch
extends Property

Searching in raster images.

See Also:
RasterSearch.java

Field Summary
static int ERR_MAE
          Error metrics: Mean Absolute Error (average of absolute differences of individual samples).
static int ERR_RMSE
          Error metrics: Root Mean Squared Error (average of squared differences of individual samples, square root of that average).
static int MAX_REFERENCE
          Maximum number of reference images.
static int ORI_0123
          Orientation: original (0123 from upper left to lower right corner).
static int ORI_0213
          Orientation: mirror of ORI_0123.
static int ORI_1032
          Orientation: mirror of ORI_2031.
static int ORI_1302
          Orientation: 270-degree rotation of ORI_0123.
static int ORI_2031
          Orientation: 90-degree rotation of ORI_0123.
static int ORI_2301
          Orientation: mirror of ORI_1302.
static int ORI_3120
          Orientation: mirror of ORI_3210.
static int ORI_3210
          Orientation: 180-degree rotation of ORI_0123.
static int ORI_FAIL
          Result code for failed search.
static int[][] ORI_INV
          Transform matrices from destination space [x,y] to source space [u,v].
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
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.
 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.
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 

Field Detail

ERR_MAE

static final int ERR_MAE
Error metrics: Mean Absolute Error (average of absolute differences of individual samples).

See Also:
Constant Field Values

ERR_RMSE

static final int ERR_RMSE
Error metrics: Root Mean Squared Error (average of squared differences of individual samples, square root of that average).

See Also:
Constant Field Values

ORI_0123

static final int ORI_0123
Orientation: original (0123 from upper left to lower right corner).

See Also:
Constant Field Values

ORI_0213

static final int ORI_0213
Orientation: mirror of ORI_0123.

See Also:
Constant Field Values

ORI_2031

static final int ORI_2031
Orientation: 90-degree rotation of ORI_0123.

See Also:
Constant Field Values

ORI_1032

static final int ORI_1032
Orientation: mirror of ORI_2031.

See Also:
Constant Field Values

ORI_3210

static final int ORI_3210
Orientation: 180-degree rotation of ORI_0123.

See Also:
Constant Field Values

ORI_3120

static final int ORI_3120
Orientation: mirror of ORI_3210.

See Also:
Constant Field Values

ORI_1302

static final int ORI_1302
Orientation: 270-degree rotation of ORI_0123.

See Also:
Constant Field Values

ORI_2301

static final int ORI_2301
Orientation: mirror of ORI_1302.

See Also:
Constant Field Values

ORI_FAIL

static final int ORI_FAIL
Result code for failed search.

See Also:
Constant Field Values

ORI_INV

static final int[][] ORI_INV
Transform matrices from destination space [x,y] to source space [u,v]. Code to compute source coordinates:
 int x, y, size;    // destination coordinates and rectangle size
 int ori;           // orientation
 ...
 int[] tr = ORI_INV[ ori ];
 int u = x * tr[0] + y * tr[1] + (size-1) * tr[2];
 int v = x * tr[3] + y * tr[4] + (size-1) * tr[5];
 


MAX_REFERENCE

static final int MAX_REFERENCE
Maximum number of reference images.

See Also:
Constant Field Values
Method Detail

setReferencePicture

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..

Parameters:
g - Read-only raster image (can be null to reset the slot).
id - Reference image identifier (0, 1, .. 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:
ORI_0123

setSearchParameters

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.

Parameters:
oriMask - Mask of valid orientations to search (1 << ORI_0123, ..).
bandMask - Mask of searched image bands (Red .. 1, Green .. 2, Blue .. 4, ..).
metrics - One of {ERR_MAE, 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

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.

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 ORI_FAIL in case of failure).