anthonynsimon / bild

Image processing algorithms in pure Go
MIT License
4.02k stars 214 forks source link

Add the ability to pass heuristics value in effect.Grayscale #65

Closed ajatprabha closed 5 years ago

ajatprabha commented 5 years ago

The current implementation uses 0.3R + 0.6G + 0.1B as the heuristic which produces choppy results on certain images. I've found that 0.299R + 0.587G + 0.114B produces much better results. There should be a way to set this heuristic.

anthonynsimon commented 5 years ago

Hey check out this PR: https://github.com/anthonynsimon/bild/pull/67

Let me know if that's what you're after.

ajatprabha commented 5 years ago

Yes, that solves this issue. Although, image.Gray throughs away transparency while grayscaling because there's no Alpha information. Do you have a solution on that?

I ended up with this meanwhile.
https://github.com/gojek/darkroom/blob/e1c6479f6235312b186521c7b76dd91992168d17/pkg/processor/native/processor.go#L83-L101

anthonynsimon commented 5 years ago

@ajatprabha thanks for the feedback. I modified it to now return a proper image.RGBA instead of the single channel image.Gray. Hope this resolves the issue!

ajatprabha commented 5 years ago

Awesome @anthonynsimon Hope this gets merged soon.