public class TemplateMatcher
extends java.lang.Object
| Constructor | Description |
|---|---|
TemplateMatcher(java.awt.image.BufferedImage image,
java.awt.Shape maskShape) |
Constructs a TemplateMatcher object.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.awt.image.BufferedImage |
buildTemplate(java.awt.image.BufferedImage image,
int alphaInput,
int alphaOriginal) |
Builds the template from an input image.
|
static int |
getAlpha(int value) |
Method to get the alpha component from a color value
|
int[] |
getAlphas() |
Gets the alphas used to build the most recent template.
|
static int |
getBlue(int value) |
Method to get the blue component from a color value
|
static int |
getGreen(int value) |
Method to get the green component from a color value
|
int |
getIndex() |
Gets the index.
|
java.awt.image.BufferedImage |
getMatchImage() |
Gets the most recent match image.
|
TPoint |
getMatchLocation(java.awt.image.BufferedImage target,
java.awt.Rectangle searchRect) |
Gets the template location at which the best match occurs in a rectangle.
|
TPoint |
getMatchLocation(java.awt.image.BufferedImage target,
java.awt.Rectangle searchRect,
double x0,
double y0,
double theta,
int spread) |
Gets the template location at which the best match occurs in a
rectangle and along a line.
|
double[] |
getMatchWidthAndHeight() |
Returns the width and height of the peak for the most recent match.
|
static int |
getRed(int value) |
Method to get the red component from a color value
|
java.util.ArrayList<java.awt.geom.Point2D> |
getSearchPoints(java.awt.Rectangle searchRect,
double x0,
double y0,
double theta) |
Gets a list of Point2D objects that lie within pixels in a rectangle
and along a line.
|
java.awt.image.BufferedImage |
getTemplate() |
Gets the template.
|
static int |
getValue(int a,
int argb) |
Method to get the color value
|
static int |
getValue(int a,
int r,
int g,
int b) |
Method to get the color value
|
int[] |
getWorkingPixels(int[] pixels) |
Gets the working image pixels used to generate the template.
|
void |
setIndex(int index) |
Sets the index.
|
void |
setTemplate(java.awt.image.BufferedImage image) |
Sets the template to be used for the next search.
|
void |
setWorkingPixels(int[] pixels) |
Sets the working image pixels used to generate the template.
|
public TemplateMatcher(java.awt.image.BufferedImage image,
java.awt.Shape maskShape)
image - the image to matchmaskShape - a shape to define inside pixels (may be null)public void setTemplate(java.awt.image.BufferedImage image)
image - the template imagepublic java.awt.image.BufferedImage getTemplate()
public java.awt.image.BufferedImage buildTemplate(java.awt.image.BufferedImage image,
int alphaInput,
int alphaOriginal)
image - the input imagealphaInput - the opacity with which the input image is overlaid (0-255)alphaOriginal - the opacity with which the original image is overlaid (0-255)public int[] getAlphas()
public void setIndex(int index)
index - the indexpublic int getIndex()
public int[] getWorkingPixels(int[] pixels)
pixels - int[] of pixels. If null, it will be createdpublic void setWorkingPixels(int[] pixels)
pixels - int[] of pixelspublic TPoint getMatchLocation(java.awt.image.BufferedImage target, java.awt.Rectangle searchRect)
target - the image to searchsearchRect - the rectangle to search within the target imagepublic TPoint getMatchLocation(java.awt.image.BufferedImage target, java.awt.Rectangle searchRect, double x0, double y0, double theta, int spread)
target - the image to searchsearchRect - the rectangle to search within the target imagex0 - the x-component of a point on the liney0 - the y-component of a point on the linetheta - the angle of the linespread - the spread of the line (line width = 1+2*spread)public java.awt.image.BufferedImage getMatchImage()
public double[] getMatchWidthAndHeight()
public static int getValue(int a,
int argb)
a - 0-255 alphaargb - current color valuepublic static int getValue(int a,
int r,
int g,
int b)
a - 0-255 alphar - 0-255 redg - 0-255 greenb - 0-255 bluepublic static int getAlpha(int value)
value - the color valuepublic static int getRed(int value)
value - the color valuepublic static int getGreen(int value)
value - the color valuepublic static int getBlue(int value)
value - the color valuepublic java.util.ArrayList<java.awt.geom.Point2D> getSearchPoints(java.awt.Rectangle searchRect,
double x0,
double y0,
double theta)
searchRect - the rectanglex0 - the x-component of a point on the liney0 - the y-component of a point on the linetheta - the angle of the line