Skip to content

Add autocontrast_preserve#1246

Closed
broxeph wants to merge 3 commits intopython-pillow:masterfrom
broxeph:master
Closed

Add autocontrast_preserve#1246
broxeph wants to merge 3 commits intopython-pillow:masterfrom
broxeph:master

Conversation

@broxeph
Copy link
Copy Markdown

@broxeph broxeph commented May 31, 2015

Maximize (normalize) image contrast while preserving image tone. (Mimics
Photoshop autocontrast functionality as opposed to the default PIL
implementation, which operates on channels separately).

Maximize (normalize) image contrast while preserving image tone. (Mimics
Photoshop autocontrast functionality as opposed to the default PIL
implementation, which operates on channels separately).
@hugovk
Copy link
Copy Markdown
Member

hugovk commented May 31, 2015

Please could you add tests for this?

PIL/ImageOps.py (1.7%): Missing lines 150-156,158-160,162-164,167-169,171-175,177-180,182-186,188-191,193-200,202-204,206,208-218
-------------
Total:   58 lines
Missing: 57 lines
Coverage: 1%

https://travis-ci.org/python-pillow/Pillow/jobs/64760914#L3778

Docs would be very welcome too.

@broxeph
Copy link
Copy Markdown
Author

broxeph commented May 31, 2015

Not quite sure what you're looking for in terms of docs, but I added "while preserving image tone" to a copy of the autocontrast docstring.

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 93e6c08 on broxeph:master into * on python-pillow:master*.

@wiredfool
Copy link
Copy Markdown
Member

The tests that were added do show that it doesn't crash, but don't validate correctness.

Possible Additional tests:

  • GS ramp of 256 greys, cutoff n% do we get the expected number of full white/black pixels.
  • Opposite ramp in 2 color channels, constant in the other.
  • Single color image, grey, black, white. (or single channel.)
  • Synthetic image with ramp in one channel +constant value + light noise in the other channels.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n = sum(h)?

(ah. copy/paste)

@wiredfool wiredfool added this to the 3.0.0 milestone Sep 10, 2015
@wiredfool wiredfool mentioned this pull request Sep 20, 2015
@wiredfool
Copy link
Copy Markdown
Member

I've added some tests here (wiredfool@bb3ad27) for correctness of implementation, and I'm seeing some really strange behavior for running against a constant color image.

If all pixels are white, it returns a white image. (127, 255,0) returns the same. But (127,127,127) returns an image that's (127, 255, 255), and an all black image returns (0,255,255). I don't think that this is intended behavior.

@radarhere radarhere removed this from the 3.0.0 milestone Oct 7, 2015
@hugovk
Copy link
Copy Markdown
Member

hugovk commented Feb 21, 2019

I'll close this because there's been no progress in 3-4 years. Ping if you'd like to re-open it, or create a new PR. Thanks!

@radarhere
Copy link
Copy Markdown
Member

An alternative to this, #5350, has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants