• Nigel Tao's avatar
    image/color: tweak the formula for converting to gray. · 584e3ea2
    Nigel Tao authored
    This makes grayModel and gray16Model in color.go use the exact same
    formula as RGBToYCbCr in ycbcr.go. They were the same formula in theory,
    but in practice the color.go versions used a divide by 1000 and the
    ycbcr.go versions used a (presumably faster) shift by 16.
    
    This implies the nice property that converting an image.RGBA to an
    image.YCbCr and then taking only the Y channel is equivalent to
    converting an image.RGBA directly to an image.Gray.
    
    The difference between the two formulae is non-zero, but small:
    https://play.golang.org/p/qG7oe-eqHI
    
    Updates #16251
    
    Change-Id: I288ecb957fd6eceb9626410bd1a8084d2e4f8198
    Reviewed-on: https://go-review.googlesource.com/31538Reviewed-by: 's avatarRob Pike <r@golang.org>
    584e3ea2
Name
Last commit
Last update
..
color Loading commit data...
draw Loading commit data...
gif Loading commit data...
internal/imageutil Loading commit data...
jpeg Loading commit data...
png Loading commit data...
testdata Loading commit data...
decode_example_test.go Loading commit data...
decode_test.go Loading commit data...
format.go Loading commit data...
geom.go Loading commit data...
geom_test.go Loading commit data...
image.go Loading commit data...
image_test.go Loading commit data...
names.go Loading commit data...
ycbcr.go Loading commit data...
ycbcr_test.go Loading commit data...