Dictionary matching¶
sies.dictionary.descriptors ¶
Transformation-invariant shape descriptors built from CGPT matrices.
Reference: Ammari et al., Target identification using dictionary matching of generalized polarization tensors, FoCM (2014).
ShapeDescriptor
dataclass
¶
ShapeDescriptor(i1, i2)
Pair of invariant descriptors derived from a CGPT matrix.
Attributes:
| Name | Type | Description |
|---|---|---|
i1 |
(ndarray, shape(k, k))
|
First invariant descriptor (modulus of the normalized first complex CGPT). |
i2 |
(ndarray, shape(k, k))
|
Second invariant descriptor. |
from_cgpt
classmethod
¶
from_cgpt(cgpt)
Compute invariant descriptors from a CGPT matrix.
The CGPT is first recentered at the equivalent center of the shape (estimated from its own low-order entries), then normalized by its diagonal, which removes the dependence on translation, rotation and scaling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cgpt
|
ndarray, shape (2k, 2k)
|
CGPT matrix of the shape. |
required |
Returns:
| Type | Description |
|---|---|
ShapeDescriptor
|
The invariant descriptors. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the CGPT is degenerate (vanishing leading entry or diagonal), which prevents the normalization. |
Source code in src/sies/dictionary/descriptors.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
distance ¶
distance(other, order=None)
Frobenius distance between two descriptors up to a given order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
ShapeDescriptor
|
Descriptor to compare with. |
required |
order
|
int
|
Truncation order; the full descriptor is used by default. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
The combined Frobenius distance
|
Source code in src/sies/dictionary/descriptors.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
sies.dictionary.matching ¶
Dictionary matching of shape descriptors.
ShapeDictionary
dataclass
¶
ShapeDictionary(shapes, descriptors, cnd, pmtt)
A dictionary of shapes with precomputed invariant descriptors.
Attributes:
| Name | Type | Description |
|---|---|---|
shapes |
list of C2Boundary
|
The reference shapes. |
descriptors |
list of ShapeDescriptor
|
Invariant descriptor of each shape. |
cnd |
float
|
Conductivity used to compute the CGPTs. |
pmtt |
float
|
Permittivity used to compute the CGPTs. |
build
classmethod
¶
build(shapes, cnd, pmtt=0.0, order=5, freq=0.0)
Build a dictionary from a list of shapes.
The theoretical CGPT of each shape is computed by boundary integral equations and converted to invariant descriptors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapes
|
list of C2Boundary
|
The reference shapes (typically normalized to similar sizes). |
required |
cnd
|
float
|
Common conductivity of the shapes. |
required |
pmtt
|
float
|
Common permittivity. |
0.0
|
order
|
int
|
Maximum CGPT order of the descriptors. |
5
|
freq
|
float
|
Working frequency. |
0.0
|
Returns:
| Type | Description |
|---|---|
ShapeDictionary
|
The assembled dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sies/dictionary/matching.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
match ¶
match(descriptor, order=None)
Rank the dictionary shapes by similarity with a descriptor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptor
|
ShapeDescriptor
|
Descriptor of the unknown shape. |
required |
order
|
int
|
Truncation order used for the comparison. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
errors |
ndarray
|
Distance to each dictionary element. |
ranking |
ndarray
|
Dictionary indices sorted by increasing distance. |
Source code in src/sies/dictionary/matching.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
identify ¶
identify(descriptor, order=None)
Return the name of the best-matching dictionary shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptor
|
ShapeDescriptor
|
Descriptor of the unknown shape. |
required |
order
|
int
|
Truncation order used for the comparison. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Name of the identified shape. |
Source code in src/sies/dictionary/matching.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
match_descriptor ¶
match_descriptor(descriptor, dictionary, order=None)
Rank dictionary elements by similarity with a query descriptor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptor
|
ShapeDescriptor
|
Descriptor of the unknown shape. |
required |
dictionary
|
list of ShapeDescriptor
|
Descriptors of the dictionary shapes. |
required |
order
|
int
|
Truncation order used for the comparison. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
errors |
(ndarray, shape(len(dictionary)))
|
Distance between the query and each dictionary element. |
ranking |
(ndarray, shape(len(dictionary)))
|
Indices of the dictionary elements sorted by increasing
distance; |
Source code in src/sies/dictionary/matching.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |