gogh

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

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

Go to latest
Published: Nov 17, 2014 License: MIT Imports: 9 Imported by: 0

README

gogh

image processing package write in go for Computer Vision (like OpenCV)

##How To Install/Update?

go get -u github.com/ironpark/gogh

##How To Use?

Simple Examples

Binarization/Histogram

import (
	"fmt"
	"github.com/ironpark/gogh"
)


func main() {
	src := gogh.Load("some.jpg")
	//method chaining pattern!
	fmt.Println("histogram",src.Histogram().Array()) //Nomal histogram
	fmt.Println("histogram",src.Histogram().Cumulative()) //Cumulative histogram
	
	//Binarization
	src.Binarization(50, false).Save("Binarization.png")
}

Pixel Get/Set

import (
	"fmt"
	"github.com/ironpark/gogh"
)


func main() {
		src := gogh.Load("some.jpg")
		//src.At(x,y).Set(r,g,b)
		src.At(1,2).Set(0,0,0)
		
		fmt.Println(src.At(1,2).Gray())
		fmt.Println(src.At(1,2).RGBA())
}

Pixel Loop

if you want loop all pixels you can use double for loop

	src := gogh.Load("some.jpg")
	bounds := src.Bounds()
	for x := bounds.Min.X; x < bounds.Max.X; x++ {
		for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
			fmt.Println(c.At(x, y).Gray()
		}
	}

it is same fuction more than simple

	src.Loop(func(x, y int) {
		fmt.Println(src.At(x, y).Gray())
	})

Blur

import (
	"fmt"
	"github.com/ironpark/gogh"
)

func main() {
	img := gogh.Load("some.jpg")
	img.Blur(3, gogh.BLUR_BOX).Filter(sobel).Save("5.png")
}

Convolution Filter

import (
	"fmt"
	"github.com/ironpark/gogh"
	"github.com/ironpark/gogh/mask"
)
var (
	sobel = [][]float32{
		{-1, 0, 1},
		{-2, 0, 2},
		{-1, 0, 1},
	}
)

func main() {
	img := gogh.Load("some.jpg")
	
	img.Filter(sobel).Save("Sobel1.png")
	//same code
	img.Filter(mask.SobelMask3x3X).Save("Sobel2.png")
	
	//Box Blur
	img.Filter(mask.GenBoxBlurMask(3)).Save("BoxBlur1.png")
	//or
	img.Blur(3, gogh.BLUR_BOX).Save("BoxBlur2.png")
	
}

Documentation

Overview

gogh document

gogh project gogh.go

Index

Constants

View Source
const (
	BLUR_BOX    = 0
	BLUR_MEDIAN = 1
)
View Source
const (
	GRAY    = 0
	GRAY16  = 1
	NRGBA   = 3
	NRGBA64 = 4
	RGBA    = 5
	RGBA64  = 6
)
View Source
const (
	Kb = 0.0722
	Kr = 0.2126
)

Variables

This section is empty.

Functions

func Color

func Color(colors ...uint8) []uint8

Types

type Img

type Img struct {
	Pixels    []uint8
	ImageType int
	Width     int
	Height    int
	Bounds    image.Rectangle
	// contains filtered or unexported fields
}

func Load

func Load(path string) *Img

func NewImg

func NewImg(rect image.Rectangle, T int) *Img

func (*Img) At

func (img *Img) At(x, y int) *Pixel

func (*Img) Binarization

func (src *Img) Binarization(T int, reverse bool) *Img

func (*Img) Blur

func (src *Img) Blur(blurtype, size int) *Img

func (*Img) Canny

func (src *Img) Canny(th_high, th_low int) *Img

func (*Img) Clone

func (src *Img) Clone() *Img

func (*Img) Draw

func (src *Img) Draw(s shape.Shape, x, y int, color interface{})

func (*Img) Filter

func (src *Img) Filter(mask interface{}, value ...int) *Img

func (*Img) FindEdge

func (src *Img) FindEdge(maskX, maskY [][]float32, t int) *Img

func (*Img) Grayscale

func (src *Img) Grayscale() *Img

func (*Img) Histogram

func (src *Img) Histogram() *histogram

func (*Img) Loop

func (src *Img) Loop(some func(int, int, *Pixel))

func (*Img) MedianBlur

func (src *Img) MedianBlur(size int) *Img

func (*Img) Save

func (src *Img) Save(path string)

type Pixel

type Pixel struct {
	X         int
	Y         int
	ImageType int
	// contains filtered or unexported fields
}

func (*Pixel) Gray

func (src *Pixel) Gray() int

func (*Pixel) RGBA

func (src *Pixel) RGBA() (int, int, int, int)

TEMP!!! YOU MUST FIX!!

func (*Pixel) Set

func (src *Pixel) Set(color ...interface{})

Slow?

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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