Template Transposto
Operações Binárias em Templates

Qualquer operação binária \( \gamma \) em \( \mathbb{F} \) induz uma operação em \( (\mathbb{F}^{\mathbf{X}})^{\mathbf{Y}} \) de modo que se \( \mathbf{s}, \mathbf{t} \in (\mathbb{F}^{\mathbf{X}})^{\mathbf{Y}} \), então:
Exemplo com Soma
Por exemplo, se \( \mathbb{F} = \mathbb{R} \), \( \mathbf{s}, \mathbf{t} \in (\mathbb{R}^{\mathbf{X}})^{\mathbf{Y}} \) e \( \gamma = + \):
ou seja, a operação corresponde à soma pontual entre as imagens \( \mathbf{s}_{\mathbf{y}} \in \mathbb{R}^{\mathbf{X}} \) e \( \mathbf{t}_{\mathbf{y}} \in \mathbb{R}^{\mathbf{X}} \).
Operações Unárias: Redução Global
Já entre as operações unárias temos a redução global. Se \( \mathbf{Y} = \{\mathbf{y}_1, \ldots, \mathbf{y}_n\} \) é um conjunto finito de pontos e \( \mathbf{t} \in (\mathbb{F}^{\mathbf{X}})^{\mathbf{Y}} \), então a operação \( \gamma \) em \( \mathbb{F} \) induz:
definida por:
Exemplo: Soma de Imagens

Exemplificando com \( \mathbb{F} = \mathbb{R} \) e \( \gamma = + \) temos:
correspondendo à soma de um número finito de imagens.
Produto de Convolução entre Templates

Já no caso em que temos \( (\mathbb{F}, \gamma, \circ) \) como um anel (ou semi-anel) podemos definir o produto de convolução entre templates:
definida de modo que dado \( \mathbf{s} \in (\mathbb{F}^{\mathbf{Z}})^{\mathbf{X}} \), \( \mathbf{t} \in (\mathbb{F}^{\mathbf{X}})^{\mathbf{Y}} \) e \( \mathbf{X} \) um conjunto finito de pontos, então \( \mathbf{r} = \mathbf{s} \textcircled{$\gamma$} \mathbf{t} \) é definido por:
Caso Linear
No exemplo em que \( \mathbb{F} = \mathbb{R} \), temos \( \mathbf{r} = \mathbf{s} \oplus \mathbf{t} \) dada por:
Caso Max Morfológico
O produto de reticulado \( \mathbf{r} = \mathbf{s} \boxed{\vee} \mathbf{t} \) se define similarmente para \( \mathbf{s} \in (\mathbb{R}^{\mathbf{Z}}_{\pm\infty})^{\mathbf{X}} \) e \( \mathbf{t} \in (\mathbb{R}^{\mathbf{X}}_{\pm\infty})^{\mathbf{Y}} \):
Exemplo: Produto entre Templates

Exemplos: Sejam \( \mathbf{s}, \mathbf{t} \in (\mathbb{R}^{\mathbb{Z}^2})^{\mathbb{Z}^2} \) com valores:
Templates
(valores sublinhados indicam o pixel central)
Vamos calcular o produto \( \mathbf{r} = \mathbf{s} \oplus \mathbf{t} \) lembrando que:
Cálculo de \( r_{(2,2)}(1, 1) \)
[ r_{(2,2)}(1, 1) = s_{(1,1)}(1, 1) \cdot t_{(2,2)}(1, 1) + s_{(1,2)}(1, 1) \cdot t_{(2,2)}(1, 2) + s_{(1,3)}(1, 1) \cdot t_{(2,2)}(1, 3) + ] [ s_{(2,1)}(1, 1) \cdot t_{(2,2)}(2, 1) + s_{(2,2)}(1, 1) \cdot t_{(2,2)}(2, 2) + s_{(2,3)}(1, 1) \cdot t_{(2,2)}(2, 3) + ] [ s_{(3,1)}(1, 1) \cdot t_{(2,2)}(3, 1) + s_{(3,2)}(1, 1) \cdot t_{(2,2)}(3, 2) + s_{(3,3)}(1, 1) \cdot t_{(2,2)}(3, 3) ] [ = 2 \cdot 0 + 1 \cdot 1 + 0 \cdot 0 + 0 \cdot 0 + 0 \cdot 3 + 0 \cdot 0 + 0 \cdot 0 + 0 \cdot (-1) + 0 \cdot 0 = 1 ]
Resultado do Produto

Cálculo de \( r_{(2,2)}(2, 2) \)
[ r_{(2,2)}(2, 2) = s_{(1,1)}(2, 2) \cdot t_{(2,2)}(1, 1) + s_{(1,2)}(2, 2) \cdot t_{(2,2)}(1, 2) + s_{(1,3)}(2, 2) \cdot t_{(2,2)}(1, 3) + ] [ s_{(2,1)}(2, 2) \cdot t_{(2,2)}(2, 1) + s_{(2,2)}(2, 2) \cdot t_{(2,2)}(2, 2) + s_{(2,3)}(2, 2) \cdot t_{(2,2)}(2, 3) + ] [ s_{(3,1)}(2, 2) \cdot t_{(2,2)}(3, 1) + s_{(3,2)}(2, 2) \cdot t_{(2,2)}(3, 2) + s_{(3,3)}(2, 2) \cdot t_{(2,2)}(3, 3) ] [ = 0 \cdot 0 + 0 \cdot 1 + 0 \cdot 0 + 1 \cdot 0 + 2 \cdot 3 + 1 \cdot 0 + 0 \cdot 0 + 0 \cdot (-1) + 0 \cdot 0 = 6 ]
Resultado Final
No final o produto \( \mathbf{r} = \mathbf{s} \oplus \mathbf{t} \) será:
Interpretação
O produto de convolução entre templates gera um novo template que combina as características de ambos. Neste exemplo, o template horizontal \( \mathbf{s} \) combinado com o template vertical \( \mathbf{t} \) produz um template 3×3.
Resumo
| Conceito | Definição |
|---|---|
| Operação binária | \( (\mathbf{s} \gamma \mathbf{t})_{\mathbf{y}} = \mathbf{s}_{\mathbf{y}} \gamma \mathbf{t}_{\mathbf{y}} \) |
| Redução global | \( \Gamma \mathbf{t} = \mathbf{t}_{\mathbf{y}_1} \gamma \ldots \gamma \mathbf{t}_{\mathbf{y}_n} \) |
| Produto linear | \( \mathbf{r}_{\mathbf{y}}(\mathbf{z}) = \sum_{\mathbf{x}} \mathbf{s}_{\mathbf{x}}(\mathbf{z}) \cdot \mathbf{t}_{\mathbf{y}}(\mathbf{x}) \) |
| Produto max | \( \mathbf{r}_{\mathbf{y}}(\mathbf{z}) = \bigvee_{\mathbf{x}} [\mathbf{s}_{\mathbf{x}}(\mathbf{z}) + \mathbf{t}_{\mathbf{y}}(\mathbf{x})] \) |
Exemplo: Produto Max Morfológico

Já se \( \mathbf{s}, \mathbf{t} \in (\mathbb{R}^{\mathbb{Z}^2}_{\pm\infty})^{\mathbb{Z}^2} \) são definidos com \( -\infty \) fora do suporte, podemos obter o produto \( \mathbf{r} = \mathbf{s} \boxed{\vee} \mathbf{t} \):
Associatividade e Separabilidade

Vamos agora redefinir \( \mathbf{t} \) para um template \( \mathbb{R}^{\geq 0}_{\infty} \)-valorado:
Assim podemos calcular \( \mathbf{r} = \mathbf{s} \boxed{\vee} \mathbf{t} \):
Propriedade Fundamental
A grande utilidade de produtos de templates resulta da seguinte igualdade válida em semi-anéis:
o que permite, por exemplo, transformar uma convolução bidimensional no produto de duas unidimensionais, e assim reduzir cálculos.
Exemplo: Templates Cruz

Considere os templates a seguir:
Template s
| 3 | ||
| -1 | 2 | 1 |
Template t
| 1 | ||
| 2 | 3 | 1 |
| -1 |
(Valores em negrito indicam o pixel central)
Soma de Templates

Vamos calcular a soma \( \mathbf{r} = \mathbf{s} + \mathbf{t} \) usando um sistema de coordenadas centrado no template:
- \( \mathbf{r}_{(0,0)}(0, 0) = \mathbf{s}_{(0,0)}(0, 0) + \mathbf{t}_{(0,0)}(0, 0) = 2 + 3 = 5 \)
- \( \mathbf{r}_{(0,0)}(1, 0) = \mathbf{s}_{(0,0)}(1, 0) + \mathbf{t}_{(0,0)}(1, 0) = 0 + (-1) = -1 \)
- \( \mathbf{r}_{(0,0)}(-1, 0) = \mathbf{s}_{(0,0)}(-1, 0) + \mathbf{t}_{(0,0)}(-1, 0) = 3 + 1 = 4 \)
- \( \mathbf{r}_{(0,0)}(0, 1) = \mathbf{s}_{(0,0)}(0, 1) + \mathbf{t}_{(0,0)}(0, 1) = 1 + 1 = 2 \)
- \( \mathbf{r}_{(0,0)}(0, -1) = \mathbf{s}_{(0,0)}(0, -1) + \mathbf{t}_{(0,0)}(0, -1) = -1 + 2 = 1 \)
Resultado da Soma
| 4 | ||
| 1 | 5 | 2 |
| -1 |
Convolução de Templates Cruz

Outra operação é a convolução \( \mathbf{r} = \mathbf{s} \oplus \mathbf{t} \):
Cálculos
r(0,0)(0, 0): [ \mathbf{r}{(0,0)}(0, 0) = \mathbf{s}}(0, 0) \cdot \mathbf{t{(0,0)}(0, 0) + \mathbf{s}}(0, 0) \cdot \mathbf{t{(0,0)}(1, 0) + ] [ \mathbf{s}}(0, 0) \cdot \mathbf{t{(0,0)}(0, -1) + \mathbf{s}(0, 1) ] [ = 6 - 3 + 2 - 1 = 4 ]}(0, 0) \cdot \mathbf{t}_{(0,0)
r(0,0)(1, 0): [ \mathbf{r}{(0,0)}(1, 0) = \mathbf{s}(1, 0) = -2 ]}(1, 0) \cdot \mathbf{t}_{(0,0)
r(0,0)(-1, 0): [ \mathbf{r}{(0,0)}(-1, 0) = \mathbf{s}}(-1, 0) \cdot \mathbf{t{(0,0)}(-1, 0) + \mathbf{s}(0, 0) = 2 + 9 = 11 ]}(-1, 0) \cdot \mathbf{t}_{(0,0)
r(0,0)(1, 1): [ \mathbf{r}{(0,0)}(1, 1) = \mathbf{s}(1, 0) = -1 ]}(1, 1) \cdot \mathbf{t}_{(0,0)
Resultado da Convolução
| 3 | ||||
| 5 | 11 | 2 | ||
| -2 | 1 | 4 | 5 | 1 |
| 1 | -2 | -1 |
Expansão do Suporte
Note que a convolução de dois templates cruz resulta em um template com suporte expandido (5×5 em vez de 3×3 na soma).