Commit Graph

43 Commits

Author SHA1 Message Date
Rolf Eike Beer
7a4af2b767 fix unaligned accesses by using memcpy() 2019-06-29 21:04:11 +02:00
Hugo
08c47925d0
Added an image.entropy() method (#3608)
Added an `image.entropy()` method
2019-06-29 10:12:34 +03:00
Andrew Murray
1a71faf8ea Removed variable 2019-06-26 19:15:47 +10:00
Alexander Böhn
7b815a5f1d Added an image.entropy() method
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
2019-06-26 19:15:47 +10:00
Jayakrishna Menon
37516fb665 adding an upper limit for blocks_max in _set_blocks_max 2019-06-26 19:08:07 +10:00
Andrew Murray
e131fa22e2 Fixed reading and saving for TIFF and IM in PA mode 2019-05-11 14:43:48 +10:00
Andrew Murray
dba38912fb Allow putpalette for LA and PA 2019-03-29 23:13:50 +11:00
Andrew Murray
97c2848963 Fixed deprecation warnings 2019-03-26 13:50:57 +11:00
cgohlke
86afcfd8f9
Fix possible integer overflow 2019-01-25 15:11:22 -08:00
Hugo
78bc4da131
Merge pull request #3350 from radarhere/custom_tags
Added custom int and float TIFF tags
2018-12-26 13:07:46 +02:00
Hugo
55e5b7de6c
Merge pull request #3393 from frenzymadness/CWE_fixes_master
Fixes for issues reported by static code analysis
2018-12-26 13:02:19 +02:00
Andrew Murray
49b23157c4 Include header 2018-12-13 19:18:17 +11:00
Andrew Murray
7172a44caa Added libjpegturbo to check_feature 2018-12-12 21:25:05 +11:00
Andrew Murray
ddf8593e7b Do not write custom tags with libtiff < 4 2018-11-12 06:14:04 +11:00
Nazime
86324a842d Add setting negative pixels and unittest 2018-10-15 12:51:24 +02:00
Nazime
468c405a47 Image pixels negative index 2018-10-14 16:12:58 +02:00
Lumir Balhar
78bf8ea041 Fix potential leaked storage issues (CWE-772) 2018-10-02 14:06:21 +02:00
Hugo
0c71792818
Merge pull request #3251 from radarhere/conversion
Fixed implicit conversion warnings
2018-09-29 17:38:11 +03:00
Andrew Murray
1e305380ae
Merge pull request #3094 from hugovk/add-width-to-shapes
Add line width parameter to rectangle and ellipse-based shapes
2018-09-29 23:21:03 +10:00
Martin Packman
0b3036454c Give correct extrema for I;16 format images
Currently gives None for a 16 bit greyscale image rather than the
true min and max values in the 0-65536 range. The internal
ImagingGetProjection function already supports I;16 but the
_getextrema needs to know to unpack the result.
2018-09-18 13:48:12 +01:00
Hugo
6fc1e79e96 Remove ununsed draw_point. Only draw_points is used by ImageDraw.py 2018-08-25 18:56:50 +03:00
Hugo
bdf2705cd3 Remove ununsed draw_line. Only draw_lines is used by ImageDraw.py 2018-08-25 18:56:50 +03:00
Andrew Murray
f0a5946c6e Fixed implicit conversion warnings 2018-08-25 00:54:29 +10:00
Rolf Eike Beer
b565f45d77 avoid invalid free if out of memory
The surrounding code suggests this should only be freed if it was allocated
locally.
2018-07-04 20:40:12 +02:00
Hugo
d6e3ef85c2 Add width parameter to arc, chord, ellipse, pieslice 2018-07-02 11:26:42 +03:00
Hugo
9dedbff713 Add width parameter to rectangle 2018-07-02 11:21:30 +03:00
Hugo
af552801c2
Merge pull request #3186 from danpla/tga-write-rle
TGA: Add support for writing RLE data
2018-07-01 22:00:03 +03:00
Hugo
2b09e7fa6a
Merge pull request #3099 from uploadcare/lut-numpy
NumPy support for LUTs
2018-07-01 13:18:03 +03:00
Daniel Plakhotich
1d20056234 TGA: Add support for writing RLE data 2018-06-15 23:01:06 +03:00
Andrew Murray
57c7a51b51 Renamed CLIP to CLIP8 2018-04-21 18:14:05 +10:00
Andrew Murray
99dcc57720 Moved CLIP definitions into ImagingUtils.h 2018-04-21 16:35:58 +10:00
Alexander
d117026511 fix float16tofloat32 2018-04-15 01:46:26 +03:00
Alexander
4c983674c0 avoid compilation varnings 2018-04-15 01:20:57 +03:00
Alexander
497e9d8251 full buffer support 2018-04-15 00:33:15 +03:00
Alexander
2c87242027 Support for many many LUT source on C level 2018-04-14 23:12:28 +03:00
Alexander
aba478abba Raise error if it is occurred during conversion in getlist 2018-04-14 17:13:05 +03:00
Alexander
71f643e1ea doesn't affect accuracy, but a bit faster 2018-03-29 11:57:37 +03:00
Alexander
5f0b7ee73e More tests 2018-03-26 22:30:55 +03:00
Alexander
696ae12b37 3D to 3D implementation 2018-03-26 14:14:52 +03:00
Alexander
d2d546d4ae Python to C bridge 2018-03-26 11:26:51 +03:00
Metallicow
22a59ac839 Trim trailing whitespace src dir 2018-01-27 00:02:56 -06:00
Eric Soroos
4bc33d3e4a Remove _imaging.crc32 in favor or builtin python crc32 implementation 2018-01-05 15:53:50 +00:00
wiredfool
0bb3f4fee9 source layout reorg 2017-12-28 14:49:47 +00:00