diff options
author | Jack <jackdeng@gmail.com> | 2015-09-23 19:54:07 -0700 |
---|---|---|
committer | Jack <jackdeng@gmail.com> | 2015-09-23 19:54:07 -0700 |
commit | f43d35507827216071896cae83544fef1c4c35eb (patch) | |
tree | 0cb6c86ff618a0ecd756e81f38bec2ed2c6986c7 /Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go | |
parent | 396a535f1001526cde60e77f8fc5e571bf4d882b (diff) | |
download | chat-f43d35507827216071896cae83544fef1c4c35eb.tar.gz chat-f43d35507827216071896cae83544fef1c4c35eb.tar.bz2 chat-f43d35507827216071896cae83544fef1c4c35eb.zip |
godep save
Diffstat (limited to 'Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go')
-rw-r--r-- | Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go b/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go deleted file mode 100644 index 9a54d5ad5..000000000 --- a/Godeps/_workspace/src/code.google.com/p/graphics-go/graphics/blur.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2011 The Graphics-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package graphics - -import ( - "code.google.com/p/graphics-go/graphics/convolve" - "errors" - "image" - "image/draw" - "math" -) - -// DefaultStdDev is the default blurring parameter. -var DefaultStdDev = 0.5 - -// BlurOptions are the blurring parameters. -// StdDev is the standard deviation of the normal, higher is blurrier. -// Size is the size of the kernel. If zero, it is set to Ceil(6 * StdDev). -type BlurOptions struct { - StdDev float64 - Size int -} - -// Blur produces a blurred version of the image, using a Gaussian blur. -func Blur(dst draw.Image, src image.Image, opt *BlurOptions) error { - if dst == nil { - return errors.New("graphics: dst is nil") - } - if src == nil { - return errors.New("graphics: src is nil") - } - - sd := DefaultStdDev - size := 0 - - if opt != nil { - sd = opt.StdDev - size = opt.Size - } - - if size < 1 { - size = int(math.Ceil(sd * 6)) - } - - kernel := make([]float64, 2*size+1) - for i := 0; i <= size; i++ { - x := float64(i) / sd - x = math.Pow(1/math.SqrtE, x*x) - kernel[size-i] = x - kernel[size+i] = x - } - - // Normalize the weights to sum to 1.0. - kSum := 0.0 - for _, k := range kernel { - kSum += k - } - for i, k := range kernel { - kernel[i] = k / kSum - } - - return convolve.Convolve(dst, src, &convolve.SeparableKernel{ - X: kernel, - Y: kernel, - }) -} |