bilateral

package module
v0.0.0-...-d65a33d Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 7 Imported by: 0

README

Fast Bilateral filter for Golang

GoDoc Go Report Card License

A FastBilateral filter is a non-linear, edge-preserving and noise-reducing smoothing filter for images. The intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels.

Algorithm and implementation is based on http://people.csail.mit.edu/sparis/bf/
Please cite above paper for research purpose.

Original Filtered Luminance Filtered
original



filtered
SigmaSpace: 16
SigmaRange: 0.076 (auto)
Execution time 1.22s
luminance
SigmaSpace: 16
SigmaRange: 0.76 (auto)
Execution time 348.56ms
original



filtered
SigmaSpace: 16
SigmaRange: 0.092 (auto)
Execution time 21.66s
luminance
SigmaSpace: 16
SigmaRange: 0.76 (auto)
Execution time 347.69ms
// Fast Bilateral
bilateral.Auto(m)

// Luminance Fast Bilateral
luminance.Auto(m)

Requirements

  • Golang 1.7.x

Installation

$ go get -u github.com/mdouchement/bilateral

Usage

fi, _ := os.Open("input_path")
defer fi.Close()

m, _, _ := image.Decode(fi)

start := time.Now()
fbl := bilateral.New(m, 16, 0.1)
fbl.Execute()
m2 := fbl.ResultImage() // Or use `At(x, y)` func or just use `fbl` as an image.Image for chained treatments.

fo, _ := os.Create("output_path")
defer fo.Close()

jpeg.Encode(fo, m2, &jpeg.Options{Quality: 100})

Full example

Licence

MIT. See the LICENSE for more details.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Launch linter (gometalinter --config=gometalinter.json ./...)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastBilateral

type FastBilateral struct {
	Image      image.Image
	SigmaRange float64
	SigmaSpace float64
	// contains filtered or unexported fields
}

A FastBilateral filter is a non-linear, edge-preserving and noise-reducing smoothing filter for images. The intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels.

func Auto

func Auto(m image.Image) *FastBilateral

Auto instanciates a new FastBilateral with automatic sigma values.

func New

func New(img image.Image, sigmaSpace, sigmaRange float64) *FastBilateral

New instanciates a new FastBilateral.

func (*FastBilateral) At

func (f *FastBilateral) At(x, y int) color.Color

At computes the interpolation and returns the filtered color at the given coordinates.

func (*FastBilateral) Bounds

func (f *FastBilateral) Bounds() image.Rectangle

Bounds implements image.Image interface.

func (*FastBilateral) ColorModel

func (f *FastBilateral) ColorModel() color.Model

ColorModel returns the Image's color model.

func (*FastBilateral) Execute

func (f *FastBilateral) Execute()

Execute runs the bilateral filter.

func (*FastBilateral) ResultImage

func (f *FastBilateral) ResultImage() image.Image

ResultImage computes the interpolation and returns the filtered image.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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