ImageSharp
ImageSharp copied to clipboard
Implement AutoLevel processor - Attempt 2
Prerequisites
- [x] I have written a descriptive pull-request title
- [x] I have verified that there are no overlapping pull-requests open
- [x] I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
- [x] I have provided test coverage for my change (where applicable)
Description
Implementation of #87
This PR can be interpreted as attempt 2 of the closed PR #1619. It tries to address the comments mentioned there. This processor ensures that the image remains RGB and no color distortion occurs.
Some design decisions (comments welcome):
- Not touching the Alpha channel.
- Using BT.709 luminance, as this is being used in other Normalization processors already. Original PR talks about using LAB.
- Include the sync channels option, as it was originally in ImageMagick.
Please comment if this is the correct functionality.
I'll address the bulk conversion To-do's in a later PR, as there are more (unrelated) classes that suffer from that issue.
@ynse01 Thanks for having a crack at this. The code looks great 👍
Do we have output references from ImageMagick we can compare our output with?
@ynse01 Thanks for having a crack at this. The code looks great +1
Do we have output references from ImageMagick we can compare our output with?
Good point. Let me try and make an explicit Test for it.
The HistogramEqualizationTests
seem to be unstable in CI on MacOS. I don't own a Mac, so I can't have a look in any detail.
Please advise.
I’ll have a look. It’s likely not us. ImagMagick seems to return different results on Mac
I pulled down the artifacts from the build at the bottom of this page here and compared to a local test run on my Windows machine. (I need to dig my Mac out of a box as I moved out recently)
https://github.com/SixLabors/ImageSharp/actions/runs/3117901063
Interestingly it appears that there is an issue but not with the Mac output. Look at the pixel comparison there. My output and the reference both suffer from what looks like overflow issues when calculating individual component values.
Mac CI - Left, Windows Local Right

Reference Output - Left, Windows Local Right

Thanks for the directions @JimBobSquarePants. I found an off-by-one error in the code for the separate channel option and updated that reference image accordingly.