|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensourcephysics.media.core.TemplateMatcher
public class TemplateMatcher
A class to find the best match of a template image in a target image. The match location is estimated to sub-pixel accuracy by assuming the distribution of match scores near a peak is Gaussian.
| Constructor Summary | |
|---|---|
TemplateMatcher(java.awt.image.BufferedImage image,
java.awt.Shape maskShape)
Constructs a TemplateMatcher object. |
|
| Method Summary | |
|---|---|
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 rgb)
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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)| Method Detail |
|---|
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 created
public void setWorkingPixels(int[] pixels)
pixels - int[] of pixels
public TPoint getMatchLocation(java.awt.image.BufferedImage target,
java.awt.Rectangle searchRect)
target - the image to searchsearchRect - the rectangle to search within the target image
public 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 rgb)
a - 0-255 alphargb - 0-255 color
public static int getValue(int a,
int r,
int g,
int b)
a - 0-255 alphar - 0-255 redg - 0-255 greenb - 0-255 blue
public static int getAlpha(int value)
value - the color value
public static int getRed(int value)
value - the color value
public static int getGreen(int value)
value - the color value
public static int getBlue(int value)
value - the color value
public 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||