skshapes.multiscaling package¶
Multiscale representation of shapes.
Submodules¶
skshapes.multiscaling.multiscale module¶
Generic Multiscale class.
- class skshapes.multiscaling.multiscale.Multiscale(shape, ratios=None, n_points=None, scales=None, decimation_module=None)¶
Bases:
object
Multiscale representation of a shape.
This class allows to represent a shape at different scales. The shape is represented at the origin scale and at different coarser scales. The coarser scales can be defined by three different parameters:
- the ratio of the number of points between the origin scale and the
coarser scale,
the number of points of the coarser scale,
the scale of the coarser scale.
If landmarks are defined on the origin shape, they are propagated to the coarser scales.
New scales can be added to the multiscale representation by calling the [append][skshapes.multiscaling.Multiscale.append] method. The new scale is defined by one of the three parameters described above.
Existing scales can be retrieved by calling the [at][skshapes.multiscaling.Multiscale.at] # noqa E501 method. The scale is defined by one of the three parameters described above.
Signals (point_data )defined at any scale can be propagated to the other scales. The propagation is performed in both directions from the origin to the coarser scales and from the origin to the finer scales. The propagation is done by interpolation or smoothing depending on the policies defined by the fine_to_coarse_policy and coarse_to_fine_policy parameters of the [propagate][skshapes.multiscaling.Multiscale.propagate] method.
Most of the methods of this class can be called with one of the ratio, n_points or scale parameters.
- Parameters:
shape (
polydata_type
|image_type
) – The shape at the origin scale.ratios (
Float[Tensor, '_']
|Float[ndarray, '_']
|list
[float
] |list
[int
|float
] |Int[Tensor, '_']
|Int[ndarray, '_']
|list
[int
] |None
) – The ratios of the coarser scales.n_points (
Int[Tensor, '_']
|Int[ndarray, '_']
|list
[int
] |None
) – The number of points of the coarser scales.scales (
Float[Tensor, '_']
|Float[ndarray, '_']
|list
[float
] |list
[int
|float
] |Int[Tensor, '_']
|Int[ndarray, '_']
|list
[int
] |None
) – The scales of the coarser scales.decimation_module – The decimation module to use to compute the coarser scales. If not provided, it is defined automatically.
- Raises:
NotImplementedError – If the shape is not a triangle mesh.
ValueError – If none of the ratios, n_points or scales parameters are provided or if more than one of these parameters are provided.
Examples
import skshapes as sks # load a shape shape = sks.Sphere() ratios = [0.5, 0.25, 0.125] multiscale = sks.Multiscale(shape=shape, ratios=ratios)
See the [gallery](../../../generated/gallery/#multiscaling) for more examples.
- append(*, ratio=None, n_points=None, scale=None)¶
Append a new shape.
This function can be called with one of the ratio, n_points or scale.
- at(*, ratio=None, n_points=None, scale=None)¶
Get the shape at a given ratio, number of points or scale.
- Return type:
- indice_mapping(fine_ratio, coarse_ratio)¶
Return the indice mapping from high to low resolution.
The indice mapping is a 1d tensor of integers of length equal to the number of points at the high resolution ratio. Each element of the tensor is the index of the corresponding point at the low resolution ratio.
- propagate(signal_name, from_scale=None, from_ratio=None, from_n_points=None, fine_to_coarse_policy=None, coarse_to_fine_policy=None)¶
Propagate a signal to the other scales.
The signal must be defined at the origin scale. The propagation is performed in both directions from the origin to the coarser scales and from the origin to the finer scales.
The propagation is parametrized by two policies: one for the fine to coarse propagation and one for the coarse to fine propagation. These policies are defined by the fine_to_coarse_policy and coarse_to_fine_policy parameters. If not provided, default policies are used. See the documentation of the [FineToCoarsePolicy][skshapes.types.FineToCoarsePolicy] and [CoarseToFinePolicy][skshapes.types.CoarseToFinePolicy] classes for more details.
- Parameters:
signal_name (
str
) – The name of the signal to propagate.from_scale (
int
|float
|None
) – The scale of the origin shape.from_ratio (
int
|float
|None
) – The ratio of the origin shape.from_n_points (
int
|None
) – The number of points of the origin shape.fine_to_coarse_policy (
FineToCoarsePolicy
|None
) – The policy for the fine to coarse propagation.coarse_to_fine_policy (
CoarseToFinePolicy
|None
) – The policy for the coarse to fine propagation.
- Return type: