8000 Add new color augmenters; Refactor AddToHueAndSaturation by aleju · Pull Request #319 · aleju/imgaug · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add new color augmenters; Refactor AddToHueAndSaturation #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 43 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
and `multicore.Pool.imap_batches_unordered()` to control the maximum number
of batches in the background augmentation pipeline (allows to limit
maximum RAM demands).
* Increased `max_distance` thresholds for `almost_equals()`, `exterior_almost_equals()` and `coords_almost_equals()` in `Polygon` and `LineString` from `1e-6` to `1e-4`.
* Increased `max_distance` thresholds for `almost_equals()`,
`exterior_almost_equals()` and `coords_almost_equals()` in `Polygon` and
`LineString` from `1e-6` to `1e-4`.
This should fix false-negative problems related to float inaccuracies.
* Added module `imgaug.augmenters.edges`.
* Added interface `BinaryImageColorizerIf` to `imgaug.augmenters.edges`, which
* Added interface `augmenters.edges.BinaryImageColorizerIf`, which
contains the interface for classes used to convert binary images to RGB
images.
* Added `RandomColorsBinaryImageColorizer` to `imgaug.augmenters.edges`, which
* Added `augmenters.edges.RandomColorsBinaryImageColorizer`, which
converts binary images to RGB images by sampling uniformly RGB colors for
`True` and `False` values.
* Added augmenter `Canny`, which applies canny edge detection with alpha
* Added `augmenters.edges.Canny`, which applies canny edge detection with alpha
blending and random coloring to images.
* Renamed `imgaug/external/poly_point_isect.py` to `imgaug/external/poly_point_isect_py3.py.bak`.
* Renamed `imgaug/external/poly_point_isect.py` to
`imgaug/external/poly_point_isect_py3.py.bak`.
The file is in the library only for completeness and contains python3 syntax.
`poly_point_isect_py2py3.py` is actually used.
* Added dtype gating to `dtypes.clip_()`.
Expand All @@ -25,23 +28,52 @@
* Added `augmenters.pooling.MaxPooling`. #317
* Added `augmenters.pooling.MinPooling`. #317
* Added `augmenters.pooling.MedianPooling`. #317
* Refactored `augmenters/weather.py` (general code and docstring cleanup).
* `augmenters.color.AddToHueAndSaturation`
* [rarely breaking] Refactored `AddToHueAndSaturation` to clean it up.
Re-running old code with the same seeds will now produce different
images. #319
* [rarely breaking] The `value` parameter is now interpreted by the
augmenter to return first the hue and then the saturation value to add,
instead of the other way round.
(This shouldn't affect anyb 8000 ody.) #319
* [rarely breaking] Added `value_hue` and `value_saturation` arguments,
which allow to set individual parameters for hue and saturation
instead of having to use one parameter for both (they may not be set
if `value` is already set).
This changes the order of arguments of the augmenter and code that relied
on that order will now break.
This also changes the output of
`AddToHueAndSaturation.get_parameters()`. #319
* Added `augmenters.color.AddToHue`, a shortcut for
`AddToHueAndSaturation(value_hue=...)`. #319
* Added `augmenters.color.AddToSaturation`, a shortcut for
`AddToHueAndSaturation(value_saturation=...)`. #319
* Added `augmenters.color.WithHueAndSaturation`. #319
* Added `augmenters.color.MultiplyHueAndSaturation`. #319
* Added `augmenters.color.MultiplyHue`. #319
* Added `augmenters.color.MultiplySaturation`. #319
* Refactored `augmenters/weather.py` (general code and docstring cleanup). #336


## Fixes

* Fixed an issue with `Polygon.clip_out_of_image()`,
which would lead to exceptions if a polygon had overlap with an image,
but not a single one of its points was inside that image plane.
* Fixed `imgaug.multicore` falsely not accepting `imgaug.augmentables.batches.UnnormalizedBatch`.
* Fixed `multicore` methods falsely not accepting
`augmentables.batches.UnnormalizedBatch`.
* `Rot90` now uses subpixel-based coordinate remapping.
I.e. any coordinate `(x, y)` will be mapped to `(H-y, x)` for a rotation by 90deg.
I.e. any coordinate `(x, y)` will be mapped to `(H-y, x)` for a rotation by
90deg.
Previously, an integer-based remapping to `(H-y-1, x)` was used.
Coordinates are e.g. used by keypoints, bounding boxes or polygons.
* `Invert`
* `[rarely breaking]` If `min_value` and/or `max_value` arguments were set, `uint64` is no longer a valid input array dtype for `Invert`.
* `augmenters.arithmetic.Invert`
* [rarely breaking] If `min_value` and/or `max_value` arguments were
set, `uint64` is no longer a valid input array dtype for `Invert`.
This is due to a conversion to `float64` resulting in loss of resolution.
* Fixed `Invert` in rare cases restoring dtypes improperly.
* Fixed `dtypes.gate_dtypes()` crashing if the input was one or more numpy scalars instead of numpy arrays or dtypes.
* Fixed `dtypes.gate_dtypes()` crashing if the input was one or more numpy
scalars instead of numpy arrays or dtypes.


# 0.2.9
Expand Down
6 changes: 6 additions & 0 deletions checks/check_add_to_hue_and_saturation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def main():
images_aug = iaa.AddToHueAndSaturation(value=(-255, 255), per_channel=True).augment_images([image] * 64)
ia.imshow(ia.draw_grid(images_aug))

image = ia.quokka_square((128, 128))
images_aug = []
images_aug.extend(iaa.AddToHue().augment_images([image] * 10))
images_aug.extend(iaa.AddToSaturation().augment_images([image] * 10))
ia.imshow(ia.draw_grid(images_aug, rows=2))


if __name__ == "__main__":
main()
37 changes: 37 additions & 0 deletions checks/check_multiply_hue_and_saturation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from __future__ import print_function, division

import numpy as np

import imgaug as ia
from imgaug import augmenters as iaa


def main():
image = ia.quokka_square((128, 128))
images_aug = []

for mul in np.linspace(0.0, 2.0, 10):
aug = iaa.MultiplyHueAndSaturation(mul)
image_aug = aug.augment_image(image)
images_aug.append(image_aug)

for mul_hue in np.linspace(0.0, 5.0, 10):
aug = iaa.MultiplyHueAndSaturation(mul_hue=mul_hue)
image_aug = aug.augment_image(image)
images_aug.append(image_aug)

for mul_saturation in np.linspace(0.0, 5.0, 10):
aug = iaa.MultiplyHueAndSaturation(mul_saturation=mul_saturation)
image_aug = aug.augment_image(image)
images_aug.append(image_aug)

ia.imshow(ia.draw_grid(images_aug, rows=3))

images_aug = []
images_aug.extend(iaa.MultiplyHue().augment_images([image] * 10))
images_aug.extend(iaa.MultiplySaturation().augment_images([image] * 10))
ia.imshow(ia.draw_grid(images_aug, rows=2))


if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions checks/check_with_hue_and_saturation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import print_function, division
import imgaug as ia
import imgaug.augmenters as iaa


def main():
image = ia.quokka_square(size=(128, 128))
images = []

for i in range(15):
aug = iaa.WithHueAndSaturation(iaa.WithChannels(0, iaa.Add(i*20)))
images.append(aug.augment_image(image))

for i in range(15):
aug = iaa.WithHueAndSaturation(iaa.WithChannels(1, iaa.Add(i*20)))
images.append(aug.augment_image(image))

ia.imshow(ia.draw_grid(images, rows=2))


if __name__ == "__main__":
main()
Loading
0