warp docs

parent 8e98d5e1
Pipeline #170376 passed with stages
in 6 minutes and 3 seconds
......@@ -790,8 +790,10 @@ class _BoxTransformMixins(object):
implemented).
Args:
transform (skimage.transform._geometric.GeometricTransform | ArrayLike):
scikit-image tranform or a 3x3 transformation matrix
transform (GeometricTransform | ArrayLike | Augmenter | callable):
scikit-image tranform, a 3x3 transformation matrix,
an imgaug Augmenter, or generic callable which transforms
an NxD ndarray.
input_dims (Tuple): shape of the image these objects correspond to
(only needed / used when transform is an imgaug augmenter)
......@@ -800,9 +802,6 @@ class _BoxTransformMixins(object):
inplace (bool, default=False): if True, modifies data inplace
TODO:
- [ ] Generalize so the transform can be an arbitrary matrix
Example:
>>> # xdoctest: +IGNORE_WHITESPACE
>>> transform = skimage.transform.AffineTransform(scale=(2, 3), translation=(4, 5))
......@@ -929,7 +928,8 @@ class _BoxTransformMixins(object):
corners_new = func(corners)
else:
raise NotImplementedError(
'Corner warping is not implemented yet for transform={}'.format(transform))
'Corner warping is not implemented yet for '
'transform={!r}'.format(transform))
x_pts_new = corners_new[..., 0].reshape(-1, 4)
y_pts_new = corners_new[..., 1].reshape(-1, 4)
......
......@@ -294,9 +294,9 @@ class Coords(_generic.Spatial, ub.NiceRepr):
Args:
transform (GeometricTransform | ArrayLike | Augmenter | callable):
scikit-image tranform, a transformation matrix,
an imgaug Augmenter, or callable that maps the ndarray of
coords.
scikit-image tranform, a 3x3 transformation matrix,
an imgaug Augmenter, or generic callable which transforms
an NxD ndarray.
input_dims (Tuple): shape of the image these objects correspond to
(only needed / used when transform is an imgaug augmenter)
......@@ -368,9 +368,9 @@ class Coords(_generic.Spatial, ub.NiceRepr):
except ImportError:
import warnings
warnings.warn('imgaug is not installed')
raise TypeError(type(transform))
if isinstance(transform, imgaug.augmenters.Augmenter):
return new._warp_imgaug(transform, input_dims, inplace=True)
else:
if isinstance(transform, imgaug.augmenters.Augmenter):
return new._warp_imgaug(transform, input_dims, inplace=True)
### Try to accept GDAL tranforms ###
try:
......@@ -387,9 +387,12 @@ class Coords(_generic.Spatial, ub.NiceRepr):
new_pts.append((x, y))
new.data = np.array(new_pts, dtype=new.data.dtype)
return new
elif callable(transform):
new.data = transform(new.data)
return new
### Try to accept generic callable transforms ###
if callable(transform):
new.data = transform(new.data)
return new
raise TypeError(type(transform))
new.data = kwimage.warp_points(matrix, new.data)
return new
......@@ -715,3 +718,11 @@ class Coords(_generic.Spatial, ub.NiceRepr):
collections.append(col)
ax.add_collection(col)
return collections
if __name__ == '__main__':
"""
CommandLine:
python -m kwimage.structs.coords all
"""
import xdoctest
xdoctest.doctest_module(__file__)
......@@ -84,8 +84,8 @@ class _PointsWarpMixin:
Args:
transform (GeometricTransform | ArrayLike | Augmenter | callable):
scikit-image tranform, a 3x3 transformation matrix,
an imgaug Augmenter, or generic callable (which works on 1
point at a time).
an imgaug Augmenter, or generic callable which transforms
an NxD ndarray.
input_dims (Tuple): shape of the image these objects correspond to
(only needed / used when transform is an imgaug augmenter)
......
......@@ -139,9 +139,10 @@ class _PolyWarpMixin:
Generalized coordinate transform.
Args:
transform (GeometricTransform | ArrayLike | Augmenter):
scikit-image tranform, a 3x3 transformation matrix, or
an imgaug Augmenter.
transform (GeometricTransform | ArrayLike | Augmenter | callable):
scikit-image tranform, a 3x3 transformation matrix,
an imgaug Augmenter, or generic callable which transforms
an NxD ndarray.
input_dims (Tuple): shape of the image these objects correspond to
(only needed / used when transform is an imgaug augmenter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment