img

package module
v0.0.0-...-335a4fa Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

img

golang image to gray,binaryzation,reverse color

install
go get github.com/no-bibi/img
quick start
package main

import (
	"github.com/no-bibi/img"
)

func main() {

	file, _ := img.Read(`./enter.png`)

	//to make it gray
	grayed := img.Gray(file)
	img.Encode(grayed,`./enter_grap.png`)

	//want binary ? not problem (ps:you can adjust threshold between 0 - 255)
	binary := img.Binary(grayed, 180)
	img.Encode(binary,`./enter_binary.png`)

	//want reverse ? go on with Reverse
	reverse := img.Reverse(binary)
	img.Encode(reverse,`./enter_reverse.png`)
}
result

original:


gray :


binary :


reverse :


licenses

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Binary

func Binary(img image.Image, threshold uint8) image.Image

convert img to binaryzation rbg >= threshold is black rbg < threshold is white

func Encode

func Encode(img image.Image, fp string, o ...interface{}) (err error)

save file

func Gray

func Gray(img image.Image) image.Image

convert img to gray Gray = (Red * 0.3 + Green * 0.59 + Blue * 0.11)

func Read

func Read(fp string) (img image.Image, err error)

read file

func Reverse

func Reverse(img image.Image) image.Image

convert img to reverse color

Types

This section is empty.

Jump to

Keyboard shortcuts

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