Giter Club home page Giter Club logo

imgo's Introduction

imgo

golang图像处理工具库,图像相似度计算,图像二值化(golang image process lib)

目前只支持jpg,png

GoDoc

安装

go get github.com/Comdex/imgo

示例

package main

import(
	"github.com/Comdex/imgo"
)

func main(){
    //如果读取出错会panic,返回图像矩阵img
    //img[height][width][4],height为图像高度,width为图像宽度
    //img[height][width][4]为第height行第width列上像素点的RGBA数值数组,值范围为0-255
	//如img[150][20][0]是150行20列处像素的红色值,img[150][20][1]是150行20列处像素的绿
	//色值,img[150][20][2]是150行20列处像素的蓝色值,img[150][20][3]是150行20列处像素
	//的alpha数值,一般用作不透明度参数,如果一个像素的alpha通道数值为0%,那它就是完全透明的.
    img:=imgo.MustRead("example/test.jpg")
	
	//对原图像矩阵进行日落效果处理
	img2:=imgo.SunsetEffect(img)
	
	//保存为jpeg,100为质量,1-100
	err:=imgo.SaveAsJPEG("example/new.jpg",img2,100)
	if err!=nil {
		panic(err)
	}
}

计算两张图片的余弦相似度

	cos,err:=imgo.CosineSimilarity("test1.jpg","test2.jpg")
	if err!=nil{
		panic(err)
	}
	fmt.Println(cos)

2015.8.23 update :添加使用感知哈希算法的GetFingerprint函数获取图片的“指纹”字符串

	fp,err:=imgo.GetFingerprint("test1.jpg")
	if err!=nil {
		panic(err)
	}
	fmt.Println(fp)//输出64位的01字符串

效果


原图

横向镜像imgo.HorizontalMirror

日落imgo.SunsetEffect

负片imgo.NegativeFilmEffect

调整亮度imgo.AdjustBrightness

垂直镜像imgo.VerticalMirror

更多api及帮助请访问:http://godoc.org/github.com/Comdex/imgo

版权

本项目采用MIT开源授权许可证,完整的授权说明可在LICENSE文件中找到。

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.