public class TemplateMatcher extends Object implements ImageAnalyser<FImage>
FImage
s. Template matching is
performed in the spatial domain.Modifier and Type | Class and Description |
---|---|
static class |
TemplateMatcher.Mode
Different algorithms for comparing templates to images.
|
Constructor and Description |
---|
TemplateMatcher(FImage template,
TemplateMatcher.Mode mode)
Default constructor with the template to match and the mode
with which to estimate template responses.
|
TemplateMatcher(FImage template,
TemplateMatcher.Mode mode,
Rectangle bounds)
Construct with the template to match, the mode with which to
estimate template responses and the bounds rectangle in which
to search.
|
Modifier and Type | Method and Description |
---|---|
void |
analyseImage(FImage image)
Perform template matching.
|
FValuePixel[] |
getBestResponses(int numResponses)
Get the top-N "best" responses found by the template matcher.
|
static FValuePixel[] |
getBestResponses(int numResponses,
FImage responseMap,
int offsetX,
int offsetY,
Comparator<FValuePixel> comparator)
Get the top-N "best" responses found by the template matcher.
|
FImage |
getResponseMap() |
Rectangle |
getSearchBounds() |
FImage |
getTemplate() |
int |
getXOffset() |
int |
getYOffset() |
static void |
main(String[] args)
Testing
|
void |
setSearchBounds(Rectangle searchBounds)
Set the search bounds rectangle.
|
public TemplateMatcher(FImage template, TemplateMatcher.Mode mode)
analyseImage(FImage)
, the whole image
will be searched.template
- The templatemode
- The mode.public TemplateMatcher(FImage template, TemplateMatcher.Mode mode, Rectangle bounds)
template
- The templatemode
- The mode.bounds
- The bounding box for search.public Rectangle getSearchBounds()
public void setSearchBounds(Rectangle searchBounds)
null
results in the entire image
being searched.searchBounds
- the search bounds to setpublic void analyseImage(FImage image)
analyseImage
in interface ImageAnalyser<FImage>
image
- The image to process in place.ImageAnalyser.analyseImage(org.openimaj.image.Image)
public FValuePixel[] getBestResponses(int numResponses)
numResponses
- The number of responsespublic static FValuePixel[] getBestResponses(int numResponses, FImage responseMap, int offsetX, int offsetY, Comparator<FValuePixel> comparator)
numResponses
- The number of responsesresponseMap
- The response mapoffsetX
- the amount to shift pixels in the x directionoffsetY
- the amount to shift pixels in the y directioncomparator
- the comparator for determining the "best" responsespublic int getXOffset()
getResponseMap()
to the original image
analysed by analyseImage(FImage)
.public int getYOffset()
getResponseMap()
to the original image
analysed by analyseImage(FImage)
.public FImage getResponseMap()
analyseImage(FImage)
public FImage getTemplate()
public static void main(String[] args) throws IOException
args
- IOException