stackblur

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2017 License: MIT Imports: 2 Imported by: 0

README

stackblur-go

stackblur-go is a Go port of Stackblur algorithm created by Mario Klingemann.

To quote the author this algorithm "is a compromise between Gaussian blur and Box blur, it creates much better looking blurs than Box blur, but it is 7x faster than Gaussian blur."

Comparing to the Javascript implementation the Go version is at least 50% faster (depending on the image size and blur radius), running the same image with the same bluring radius.

Benchmark
Radius Javascript Go
20 ~15ms ~7.4ms

Installation

First, install Go, set your GOPATH, and make sure $GOPATH/bin is on your PATH.

$ export GOPATH="$HOME/go"
$ export PATH="$PATH:$GOPATH/bin"

Next build the binary file.

$ go get -u github.com/esimov/stackblur-go/cmd
CLI example

The provided CLI example supports the following flags:

$ stackblur --help

Usage of stackblur:
  -gif
    	Output Gif
  -in string
    	Source
  -out string
    	Destination
  -radius int
    	Radius (default 20)

The command below will generate the blurred version of the source image.

$ stackblur -in image/sample.png -out image/output.png -radius 10

To visualize the bluring process the cli command supports the -gif flag, which if is set to true it will generate a gif image. For the parallel execution of the the bluring process and the gif visualization goroutines are used.

However if you wish only to generate the blured image, because of API constraints you need to create a go channel and use this as the last parameter of the Process method. Something like the code below:

var done chan struct{} = make(chan struct{}, *radius)
stackblur.Process(src, uint32(src.Bounds().Dx()), uint32(src.Bounds().Dy()), uint32(*radius), done)
<-done
Original image Stackblured image

License

This project is under the MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(src image.Image, width, height, radius uint32, done chan<- struct{}) image.Image

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL