Coder Social home page Coder Social logo

bild's Introduction

bild

bild logo

MIT License GoDoc Build Status Go Report Card

Simple image processing in Go with parallel processing support.

The aim of this project is simplicity in use and development over high performance, but most algorithms are designed to be efficient and make use of parallelism when available. It is based on standard Go packages to reduce dependency use and development abstractions.

Package bild provides a collection of common image processing functions. The input images must implement the image.Image interface and the functions return an *image.RGBA.

Notice: This package is under heavy development and the API might change at any time until a 1.0 version is reached.

Documentation

http://godoc.org/github.com/anthonynsimon/bild

Install

bild requires Go version 1.4 or greater.

go get -u github.com/anthonynsimon/bild/...

Notice the '...' at the end, this is to signify that you want all the packages on the repo. In your code, simply import the specific package that you want to use (see example below).

Basic example:

package main

import (
	"github.com/anthonynsimon/bild/effect"
	"github.com/anthonynsimon/bild/imgio"
	"github.com/anthonynsimon/bild/transform"
)

func main() {
	img, err := imgio.Open("filename.jpg")
	if err != nil {
		panic(err)
	}

	inverted := effect.Invert(img)
	resized := transform.Resize(inverted, 800, 800, transform.Linear)
	rotated := transform.Rotate(resized, 45, nil)

	if err := imgio.Save("filename", rotated, imgio.PNG); err != nil {
		panic(err)
	}
}

Output examples

Adjustment

import "github.com/anthonynsimon/bild/adjust"

Brightness

result := adjust.Brightness(img, 0.25)

example

Contrast

result := adjust.Contrast(img, -0.5)

example

Gamma

result := adjust.Gamma(img, 2.2)

example

Hue

result := adjust.Hue(img, -42)

example

Saturation

result := adjust.Saturation(img, 0.5)

example

Blend modes

import "github.com/anthonynsimon/bild/blend"

result := blend.Multiply(bg, fg)
Add Color Burn Color Dodge
Darken Difference Divide
Exclusion Lighten Linear Burn
Linear Light Multiply Normal
Opacity Overlay Screen
Soft Light Subtract

Blur

import "github.com/anthonynsimon/bild/blur"

Box Blur

result := blur.Box(img, 3.0)

example

Gaussian Blur

result := blur.Gaussian(img, 3.0)

example

Channel

import "github.com/anthonynsimon/bild/channel"

Extract Channel

result := channel.Extract(img, channel.Alpha)

example

Effect

import "github.com/anthonynsimon/bild/effect"

Dilate

result := effect.Dilate(img, 3)

example

Edge Detection

result := effect.EdgeDetection(img, 1.0)

example

Emboss

result := effect.Emboss(img)

example

Erode

result := effect.Erode(img, 3)

example

Grayscale

result := effect.Grayscale(img)

example

Invert

result := effect.Invert(img)

example

Median

result := effect.Median(img, 10.0)

example

Sepia

result := effect.Sepia(img)

example

Sharpen

result := effect.Sharpen(img)

example

Sobel

result := effect.Sobel(img)

example

Histogram

import "github.com/anthonynsimon/bild/histogram"

RGBA Histogram

hist := histogram.NewRGBAHistogram(img)
result := hist.Image()

example

Noise

import "github.com/anthonynsimon/bild/noise"

Uniform colored

result := noise.Generate(280, 280, &noise.Options{Monochrome: false, NoiseFn: noise.Uniform})

example

Binary monochrome

result := noise.Generate(280, 280, &noise.Options{Monochrome: true, NoiseFn: noise.Binary})

example

Gaussian monochrome

result := noise.Generate(280, 280, &noise.Options{Monochrome: true, NoiseFn: noise.Gaussian})

example

Segmentation

Threshold

result := bild.Threshold(img, 128)

example

Transform

import "github.com/anthonynsimon/bild/transform"

Crop

// Source image is 280x280
result := transform.Crop(img, image.Rect(70,70,210,210))

example

FlipH

result := transform.FlipH(img)

example

FlipV

result := transform.FlipV(img)

example

Resize Resampling Filters

result := transform.Resize(img, 280, 280, transform.Linear)
Nearest Neighbor Linear Gaussian
Mitchell Netravali Catmull Rom Lanczos

Rotate

// Options set to nil will use defaults (ResizeBounds set to false, Pivot at center)
result := transform.Rotate(img, -45.0, nil)

example

// If ResizeBounds is set to true, the full rotation bounding area is used
result := transform.Rotate(img, -45.0, &transform.RotationOptions{ResizeBounds: true})

example

// Pivot coordinates are set from the top-left corner
// Notice ResizeBounds being set to default (false)
result := transform.Rotate(img, -45.0, &transform.RotationOptions{Pivot: &image.Point{0, 0}})

example

Shear Horizontal

result := transform.ShearH(img, 30)

example

Shear Vertical

result := transform.ShearV(img, 30)

example

License

This project is licensed under the MIT license. Please read the LICENSE file.

Contribute

Want to hack on the project? Any kind of contribution is welcome!
Simply follow the next steps:

  • Fork the project.
  • Create a new branch.
  • Make your changes and write tests when practical.
  • Commit your changes to the new branch.
  • Send a pull request.

bild's People

Contributors

anthonynsimon avatar kirilldanshin avatar radarhere avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.