Categorygithub.com/Comdex/imgo
modulepackage
0.0.0-20200213094239-bb8d436f1e5a
Repository: https://github.com/comdex/imgo.git
Documentation: pkg.go.dev

# README

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文件中找到。

# Functions

No description provided by the author
Base64ToImg create a image file named dstFile from base64 encodeString.
binaryzation process of image matrix , threshold can use 127 to test.
calculate Cosine Similarity of two images, input two file path.
decode a image and retrun golang image interface.
No description provided by the author
GetFingerprint use Perceptual Hash Algorithm to get fingerprint from a pircture.
No description provided by the author
No description provided by the author
No description provided by the author
make a mirror of src .
fuse two images(filepath) and the size of new image is as src1.
Img2Base64 produce a base64 string from a image file.
Img2base64ByGoImage produce a base64 string from Image interface.
No description provided by the author
No description provided by the author
read a image return a image matrix , if appear an error it will panic.
input a image as src , return a image matrix by negativefilmeffect process.
create a three dimenson slice.
create a new rgba matrix.
read a image return a image matrix by path or image.
resize size of image.
No description provided by the author
No description provided by the author
No description provided by the author
save a image matrix as a jpeg,if unsuccessful it will return a error,quality must be 1 to 100.
save a image matrix as a png , if unsuccessful it will return a error.
set the opacity of image matrix , opacity must be 0.0 to 1.0.
input a image matrix as src , return a image matrix by sunseteffect process.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author