wip

parent 42d226eb
Pipeline #170347 passed with stages
in 4 minutes and 48 seconds
......@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
* Boxes.scale now accepts `about` keyword arg (can use to scale about center).
* Boxes.warp now accepts matrices and does inexact corner warping
* `kwimage.warp_points` now accepts `homog_mode`
* Add `_warp_func`, which warps points using a general function to structures
### Changed
......
......@@ -440,7 +440,9 @@ def make_heatmask(probs, cmap='plasma', with_alpha=1.0, space='rgb',
heatmask[:, :, 3] = (probs * with_alpha) # assign probs to alpha channel
if dsize is not None:
import cv2
heatmask = cv2.resize(heatmask, tuple(dsize), interpolation=cv2.INTER_NEAREST)
heatmask = cv2.resize(
heatmask, tuple(dsize),
interpolation=cv2.INTER_NEAREST)
return heatmask
......
......@@ -373,6 +373,19 @@ class Coords(_generic.Spatial, ub.NiceRepr):
new.data = kwimage.warp_points(matrix, new.data)
return new
def _warp_func(self, func, inplace=False):
"""
Warp using a function that transforms points
Args:
func (callable): maps a single coordinate to a new coordinate
"""
impl = self._impl
new = self if inplace else self.__class__(impl.copy(self.data), self.meta)
dtype = self.data.dtype
new.data = np.array([func(pt) for pt in new.data], dtype=dtype)
return new
# @profile
def _warp_imgaug(self, augmenter, input_dims, inplace=False):
"""
......
......@@ -188,6 +188,21 @@ class _PolyWarpMixin:
]
return new
def _warp_func(self, func, inplace=False):
"""
Warp using a function that transforms points
Args:
func (callable): maps a single coordinate to a new coordinate
"""
new = self if inplace else self.__class__(self.data.copy())
new.data['exterior'] = new.data['exterior']._warp_func(func, inplace)
new.data['interiors'] = [
p._warp_func(func, inplace)
for p in new.data['interiors']
]
return new
def scale(self, factor, output_dims=None, inplace=False):
"""
Scale a polygon by a factor
......
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