imgo 图像二值化

来源:互联网 发布:传奇霸业辅助源码 编辑:程序博客网 时间:2024/05/03 02:51



     golang图像处理工具库 imgo 处理 图像二值化

go get github.com/Comdex/imgo 下载imgo第三方库
可以这样处理图像二值化:
package mainimport ("fmt""github.com/Comdex/imgo")func main() {imgMatrix := imgo.MustRead("rgb.png")     //获取一个[][][]uint8对象//binaryzation process of image matrix , threshold can use 127 to test//func Binaryzation(src [][][]uint8, threshold int) [][][]uint8{} imgMatrix_gray := imgo.Binaryzation(imgMatrix, 127)gray_rgb := "gray_rgb.png"err := imgo.SaveAsPNG(gray_rgb, imgMatrix_gray)if err != nil {fmt.Println(err)}fmt.Printf("%s generate finish\n", gray_rgb)}



threshold可以自己生成算法计算 的相关连接: 

        http://www.cnblogs.com/Imageshop/p/3307308.html

   如果不清楚图像二值化原理,可以看看这两篇文章

       https://segmentfault.com/a/1190000004467183
       http://www.cnblogs.com/technology/archive/2012/07/12/Perceptual-Hash-Algorithm.html



      处理前图片:

         

                   rgb.png

   

         处理后的图片效果:

               

                        gray_rgb.png

          图片效果可根据需求调整 threshold 的值


1 0