kwimage merge requestshttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests2022-06-21T21:29:38-04:00https://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/55Start branch for 0.8.72022-06-21T21:29:38-04:00Jon CrallStart branch for 0.8.7auto created mrauto created mrJon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/48Draft: Resolve "But with shear in kwimage.Affine"2021-12-16T10:50:03-05:00Jon CrallDraft: Resolve "But with shear in kwimage.Affine"Closes #8Closes #8Jon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/46Start branch for 0.7.172021-12-16T10:07:49-05:00Jon CrallStart branch for 0.7.17auto created mrauto created mrJon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/38Add imcrop and warp_affine(try_large_warp=True)2021-08-19T15:18:03-04:00Matthew BernsteinAdd imcrop and warp_affine(try_large_warp=True)Added an option to let `warp_affine` bypass [this error](https://answers.opencv.org/question/203798/shrt_max-in-cv2remap/) when calling `cv2.warpAffine` on images with a dimension `>= 32767`. This is done by splitting the image into piec...Added an option to let `warp_affine` bypass [this error](https://answers.opencv.org/question/203798/shrt_max-in-cv2remap/) when calling `cv2.warpAffine` on images with a dimension `>= 32767`. This is done by splitting the image into pieces, warping, and then merging them back together. This is not intended to be identical to the output of a non-piecewise warp; there will be small edge artifacts, though it's more than good enough for visualization purposes.
Also exposed a subtask as the option `warp_affine(dsize='max')`: when `transform` would bring image pixels into negative coordinates so they cannot be displayed, add a translation to it so that all pixels remain positive and none are discarded.
Also took the opportunity to write the cropping function I've always wanted. `imcrop` takes a string code using the `about` option to automatically figure out 9-point crops (center, corner, edge). It also handles negative coordinates, coordinates outside the image bounds, and floating-point coordinates, padding the image when necessary so that `dsize` is always respected.Jon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/31coerce to list for serialization2021-06-10T17:15:06-04:00Matthew Bernsteincoerce to list for serializationA small change to `encode_run_length` to match the expected behavior seen in `Mask.to_array_rle`.
Motivating example:
```python
import numpy as np
import kwimage as ki
import kwcoco as kc
ki.imwrite('img.png', np.zeros((10,10,3)))
ki.i...A small change to `encode_run_length` to match the expected behavior seen in `Mask.to_array_rle`.
Motivating example:
```python
import numpy as np
import kwimage as ki
import kwcoco as kc
ki.imwrite('img.png', np.zeros((10,10,3)))
ki.imwrite('seg.png', np.zeros((10,10,1)))
dset = kc.CocoDataset()
cid = dset.add_category(name='name')
gid = dset.add_image(file_name='img.png')
mask = ki.imread('seg.png')
rle = ki.encode_run_length(mask, binary=True)
ann = {
category_id: cid,
image_id: gid,
segmentation: rle
}
dset.add_annotation(**ann)
# this is a valid CocoDataset
assert not dset.validate()['errors']
# but...
dset.dump('dset.kwcoco.json')
TypeError: Object of type ndarray is not JSON serializable
```
The problem is in `rle`:
```python
{'shape': (10, 10), 'counts': array([100]), 'binary': True, 'order': 'C'}
```
Setting `rle['counts'] = rle['counts'].tolist()` fixes it. This both changes it from `np.ndarray` to `list` and coerces it from `np.int64` to base python's `int`, neither of which are sufficient alone.https://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/21Draft: Start branch for 0.6.112021-02-05T15:08:54-05:00Jon CrallDraft: Start branch for 0.6.11Jon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/13Start branch for 0.6.32020-07-08T18:54:40-04:00Jon CrallStart branch for 0.6.3Jon CrallJon Crallhttps://gitlab.kitware.com/computer-vision/kwimage/-/merge_requests/14Start branch for 0.6.42020-07-08T18:54:30-04:00Jon CrallStart branch for 0.6.4Jon CrallJon Crall