Thanks everyone for the answers and links.

I computed a pixel-to-pixel difference and indeed what I was getting was
-1/+1 differences in the gray values, due to rounding.

Next free time I'll try the other formulas.


Thank you again,

Rodolfo Carvalho

On Thu, Sep 29, 2016 at 6:12 AM, Micky <mickylmar...@gmail.com> wrote:

>
>
> On Thu, Sep 29, 2016 at 3:19 AM, Rodolfo Carvalho <rhcarva...@gmail.com>
> wrote:
>
>> gift [3]:
>>     y := 0.299*px.R + 0.587*px.G + 0.114*px.B
>>
>> I did not understand why image/color adds an extra 0.5 (500/1000) to y.
>> Could anybody give me a clue?
>>
>
> To directly answer your question:
>
> *GIFT also adds 0.5 to round off. *
>
> Wanna know where? Try to make up a call stack:
>
> gift.Grayscale() > returns Filter > is colorFilter > has a callback fn >
> returns pixel > contains float32s
>
> pixel is a struct containing float32s
> Filter is an interface, made of Draw() and Bounds()
> colorFilter implements Filter
>
> So, it eventually boils down to: [1]
>
> *colorFilter.Draw() > parallelize() > newPixelSetter().SetPixel() >
> f32u16()
>
> color.Color uses uint32s while gift.pixel uses float32s. I guess gift uses
> floats for cosmetic reasons. But they both round off while applying the
> grayscale filter.
>
> [1] https://github.com/disintegration/gift/blob/
> 703be73d60d8baeaa84c47be0d31551b466ea84a/pixels.go#L304
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to