From dc93e1b98c579d90ee2fa15c1fd6dac34f6e7899 Mon Sep 17 00:00:00 2001 From: nfnt Date: Wed, 27 May 2015 10:54:45 +0200 Subject: [PATCH] Fix wrong colors of resized image.YCbCr images. Fixes issue #31. The color value of every pixel of the resized image is created from the YCbCr colors of the input image. Therefore each of the three components have the same sample rate. This is the 4:4:4 chroma subsampling and the output images are now created accordingly. --- resize.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resize.go b/resize.go index 4d4ff6e..c167243 100644 --- a/resize.go +++ b/resize.go @@ -167,7 +167,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i // accessing the YCbCr arrays in a tight loop is slow. // converting the image to ycc increases performance by 2x. temp := newYCC(image.Rect(0, 0, input.Bounds().Dy(), int(width)), input.SubsampleRatio) - result := newYCC(image.Rect(0, 0, int(width), int(height)), input.SubsampleRatio) + result := newYCC(image.Rect(0, 0, int(width), int(height)), image.YCbCrSubsampleRatio444) coeffs, offset, filterLength := createWeights8(temp.Bounds().Dy(), taps, blur, scaleX, kernel) in := imageYCbCrToYCC(input) @@ -409,7 +409,7 @@ func resizeNearest(width, height uint, scaleX, scaleY float64, img image.Image, // accessing the YCbCr arrays in a tight loop is slow. // converting the image to ycc increases performance by 2x. temp := newYCC(image.Rect(0, 0, input.Bounds().Dy(), int(width)), input.SubsampleRatio) - result := newYCC(image.Rect(0, 0, int(width), int(height)), input.SubsampleRatio) + result := newYCC(image.Rect(0, 0, int(width), int(height)), image.YCbCrSubsampleRatio444) coeffs, offset, filterLength := createWeightsNearest(temp.Bounds().Dy(), taps, blur, scaleX) in := imageYCbCrToYCC(input)