pub enum MatchTemplateMethod {
SumOfSquaredErrors,
SumOfSquaredErrorsNormalized,
CrossCorrelation,
CrossCorrelationNormalized,
}
Expand description
Scoring functions when comparing a template and an image region.
Variants§
SumOfSquaredErrors
Sum of the squares of the difference between image and template pixel intensities. Smaller values indicate a better match.
Without a mask: $$ \text{output}(x, y) = \sum_{x’, y’} \left( \text{template}(x’, y’) - \text{image}(x+x’, y+y’) \right)^2 $$
With a mask: $$ \text{output}(x, y) = \sum_{x’, y’} \left( (\text{template}(x’, y’) - \text{image}(x+x’, y+y’)) \cdot \text{mask}(x’, y’) \right)^2 $$
SumOfSquaredErrorsNormalized
Divides the sum computed using SumOfSquaredErrors
by a normalization term. Smaller values indicate a better match.
Without a mask: $$ \text{output}(x, y) = \frac{\sum_{x’, y’} \left( \text{template}(x’, y’) - \text{image}(x+x’, y+y’) \right)^2} {\sqrt{ \sum_{x’, y’} {\text{template}(x’, y’)}^2 \cdot \sum_{x’, y’} {\text{image}(x+x’, y+y’)}^2 }} $$
With a mask: $$ \text{output}(x, y) = \frac{\sum_{x’, y’} \left( (\text{template}(x’, y’) - \text{image}(x+x’, y+y’)) \cdot \text{mask}(x’, y’) \right)^2} {\sqrt{ \sum_{x’, y’}{(\text{template}(x’, y’) \cdot \text{mask}(x’, y’))}^2 \cdot \sum_{x’, y’}{(\text{image}(x+x’, y+y’) \cdot \text{mask}(x’, y’))}^2 }} $$
CrossCorrelation
Cross Correlation. Larger values indicate a better match.
Without a mask: $$ \text{output}(x, y) = \sum_{x’, y’} \left( \text{template}(x’, y’) \cdot \text{image}(x+x’, y+y’) \right) $$
With a mask: $$ \text{output}(x, y) = \sum_{x’, y’} \left( \text{template}(x’, y’) \cdot \text{image}(x+x’, y+y’) \cdot {\text{mask}(x’, y’)}^2 \right) $$
CrossCorrelationNormalized
Divides the sum computed using CrossCorrelation
by a normalization term. Larger values indicate a better match.
Without a mask: $$ \text{output}(x, y) = \frac{\sum_{x’, y’} \left( \text{template}(x’, y’) \cdot \text{image}(x+x’, y+y’) \right)} {\sqrt{ \sum_{x’, y’} {\text{template}(x’, y’)}^2 \cdot \sum_{x’, y’} {\text{image}(x+x’, y+y’)}^2 }} $$
With a mask: $$ \text{output}(x, y) = \frac{\sum_{x’, y’} \left( \text{template}(x’, y’) \cdot \text{image}(x+x’, y+y’) \cdot {\text{mask}(x’, y’)}^2 \right)} {\sqrt{ \sum_{x’, y’}{(\text{template}(x’, y’) \cdot \text{mask}(x’, y’))}^2 \cdot \sum_{x’, y’}{(\text{image}(x+x’, y+y’) \cdot \text{mask}(x’, y’))}^2 }} $$
Trait Implementations§
source§impl Clone for MatchTemplateMethod
impl Clone for MatchTemplateMethod
source§fn clone(&self) -> MatchTemplateMethod
fn clone(&self) -> MatchTemplateMethod
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MatchTemplateMethod
impl Debug for MatchTemplateMethod
source§impl PartialEq for MatchTemplateMethod
impl PartialEq for MatchTemplateMethod
source§fn eq(&self, other: &MatchTemplateMethod) -> bool
fn eq(&self, other: &MatchTemplateMethod) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for MatchTemplateMethod
impl Eq for MatchTemplateMethod
impl StructuralPartialEq for MatchTemplateMethod
Auto Trait Implementations§
impl Freeze for MatchTemplateMethod
impl RefUnwindSafe for MatchTemplateMethod
impl Send for MatchTemplateMethod
impl Sync for MatchTemplateMethod
impl Unpin for MatchTemplateMethod
impl UnwindSafe for MatchTemplateMethod
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.