* Improve encoding of TIFF tags
- Pass tagtype from v2 directory to libtiff encoder, instead of
autodetecting type.
- Use explicit types. E.g. uint32_t for TIFF_LONG to fix issues on
platforms with 64bit longs.
- Add support for multiple values (arrays). Requires type in v2
directory and values must be passed as a tuple.
- Add support for signed types (e.g. TIFFTypes.TIFF_SIGNED_SHORT).
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
This replaces trivial instances where a copy from one pointer to the other
involves no further calculations or casts. The compiler will optimize this to
whatever the platform offers.
This calculates the entropy for the image, based on the histogram.
Because this uses image histogram data directly, the existing C
function underpinning the `image.histogram()` method was abstracted
into a static function to parse extrema tuple arguments, and a new
C function was added to calculate image entropy, making use of the
new static extrema function.
The extrema-parsing function was written by @homm, based on the
macro abstraction I wrote, during the discussion of my first
entropy-method pull request: https://git.io/fhodS
The new `image.entropy()` method is based on `image.histogram()`,
and will accept the same arguments to calculate the histogram data
it will use to assess the entropy of the image.
The algorithm and methodology is based on existing Python code:
* https://git.io/fhmIU
... A test case in the `Tests/` directory, and doctest lines in
`selftest.py`, have both been added and checked.
Changes proposed in this pull request:
* Added “math.h” include to _imaging.c
* The addition of an `image.entropy()` method to the `Image`
Python class,
* The abstraction of the extrema-parsing logic of of the C
function `_histogram` into a static function, and
* The use of that static function in both the `_histogram` and
`_entropy` C functions.
* Minor documentation addenda in the docstrings for both the
`image.entropy()` and `image.histogram()` methods were also
added.
* Removed outdated boilerplate from testing code
* Removed unused “unittest” import