Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unsharp mask #1

Closed
puzrin opened this issue Sep 22, 2014 · 2 comments
Closed

Add unsharp mask #1

puzrin opened this issue Sep 22, 2014 · 2 comments

Comments

@puzrin
Copy link
Member

puzrin commented Sep 22, 2014

For practical tasks, it's required to combine downscale with unsharp mask.

  1. For convenience, it worth to use the same prams as photoshop USM http://stackoverflow.com/questions/13296645/
  2. More to read http://stackoverflow.com/questions/2938162/
  3. Gimp implementation https://git.gnome.org/browse/gimp/tree/plug-ins/common/unsharp-mask.c
  4. Luminance / brightness math http://stackoverflow.com/questions/596216/
  5. Bugzilla discusion https://bugzilla.mozilla.org/show_bug.cgi?id=867594

Details:

  • It's ok to support only 1px blur radius. That will require minimal convolution matrix 3x3, and will be fast enougth
  • (!) unsharp luminance, not separate channels, to avoid color shift
  • (!) use high precision (> 8 bits) for luminance calculations.

Algorythm:

  1. build array of L (luminance) values (16 or 32 bits). 4x less points for convolution, as bonus.
  2. for each L point, calculate convolution, check threshold and update rgb on original if needed.
  3. additional requirements:
    • use integer math only (int32)
    • don't use division

Blur:

Other:

@puzrin
Copy link
Member Author

puzrin commented Jan 19, 2015

Implementation details:

  • Do all transforms on Luminance channel of HSL (RGB -> L -> unsharp -> RGB)
  • Blur type - Box, 2 times.
  • Integer math only (int32 max).
  • No division on hot path.
  • Optimize calculations
  • Add benchmark (blur + color corrections)

@puzrin
Copy link
Member Author

puzrin commented Nov 7, 2015

Solved by 60c6051

Will be closed after some polish & docs update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant