Skip to content

Conversation

@Franz1960
Copy link
Contributor

@Franz1960 Franz1960 commented Feb 17, 2021

…Component defines the scalar color component to be used for threshold comparison: Luminance, Saturation or MaxChroma. Luminance is default and identical to previous versions. Saturation is the HSL saturation component. MaxChroma is calculated as the maximum of YCbCr chroma value, i.e. Cb and Cr distance from achromatic value. Background: This component shall discriminate colorful parts from achromatic parts in human perception. Very dark pixels, which are perceived as near black, can have high HSL saturation values if e.g. (rgb)==(4,0,0); this would definitely not be perceived as colorful by a human. The MaxChroma component will calculate them low.

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

…Component defines the scalar color component to be used for threshold comparison: Luminance, Saturation or MaxChroma. Luminance is default and identical to previous versions. Saturation is the HSL saturation component. MaxChroma is calculated as the maximum of YCbCr chroma value, i.e. Cb and Cr distance from achromatic value. Background: This component shall discriminate colorful parts from achromatic parts in human perception. Very dark pixels, which are perceived as near black, can have high HSL saturation values if e.g. (rgb)==(4,0,0); this would definitely not be perceived as colorful by a human. The MaxChroma component will calculate them low.
@codecov
Copy link

codecov bot commented Feb 17, 2021

Codecov Report

Merging #1555 (045612f) into master (2ae6018) will increase coverage by 0.01%.
The diff coverage is 97.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1555      +/-   ##
==========================================
+ Coverage   83.57%   83.59%   +0.01%     
==========================================
  Files         742      742              
  Lines       32829    32877      +48     
  Branches     3668     3674       +6     
==========================================
+ Hits        27437    27483      +46     
- Misses       4678     4680       +2     
  Partials      714      714              
Flag Coverage Δ
unittests 83.59% <97.18%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp/ColorSpaces/YCbCr.cs 94.11% <ø> (ø)
...rocessors/Binarization/BinaryThresholdProcessor.cs 88.88% <87.50%> (-11.12%) ⬇️
...s/Binarization/BinaryThresholdProcessor{TPixel}.cs 98.59% <98.18%> (+1.62%) ⬆️
...tensions/Binarization/BinaryThresholdExtensions.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ae6018...045612f. Read the comment docs.

@JimBobSquarePants
Copy link
Member

Thanks for redoing this @Franz1960 and sorry about the runaround. The Git docs tend to describe situations that should be prefaced with "In a vacuum...".

}
else if (this.colorComponent == BinaryThresholdColorComponent.MaxChroma)
{
float fThreshold = this.threshold / 2F;
Copy link
Member

Choose a reason for hiding this comment

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

Hey @Franz1960 Can you explain this bit to me please? I'm struggling to figure out why we're halving the threshold.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The achromatic level is in the center of the Cb and Cr range, so the distance is half the range.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks... Makes sense.

One last thing. Can you please give me push permissions to your fork? I just did some optimization work on the process but do not have permissions to push for some reason (Normally I do with others).

https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork#enabling-repository-maintainer-permissions-on-existing-pull-requests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The box had been checked:
image
but as it was not giving you the necessary rights (for whatever reason) I gave you write permission to the forked repo.

@JimBobSquarePants
Copy link
Member

@Franz1960 Thanks for your patience here. Still trying to figure out LFS as I had to manually add your new files to it.

I made some changes to optimize the methods which should keep them snappy also if you're curious but I'm going to merge this now. It's awesome to have a new community feature!

@JimBobSquarePants JimBobSquarePants merged commit 6038be9 into SixLabors:master Feb 17, 2021
@Franz1960 Franz1960 deleted the max-chroma-binarization branch February 17, 2021 12:03
@Franz1960
Copy link
Contributor Author

@JimBobSquarePants Thanks too for your patience, and @antonfirsov equally. I had to learn many things. Next time will hopefully go better. Replacing submodules by LFS was for sure the right thing to do.

@antonfirsov
Copy link
Member

antonfirsov commented Feb 17, 2021

@Franz1960 thanks for the great work and also the patience towards our processes (with the submodules they were way more complicated than they should be)!

One last thing: can you add your opinion on #1556? I'd like to rename the enum today.

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.

3 participants