# DIP **Repository Path**: IBAS0742/dip ## Basic Information - **Project Name**: DIP - **Description**: dip作业 - **Primary Language**: Go - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-08 - **Last Updated**: 2021-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DIP ### 简单说明 ```text main.go 为 golang 的主函数文件的文件名, 如果 包名(package) 也为 main 则改文件中的 main 函数为主函数,可以被运行和打包 打包方法 go build -o ./release/dip2_1.exe ./DIP2_1/main.go ``` ### 目录情况 ```text + | go.mod 依赖声明和项目声明 | go.sum 类似于依赖的 hash,新建项目需要重建 | Readme.md | +---CreaetImage | main.go 主函数(测试创建 pgm 图像) | +---DIP2_1 | main.go 主函数() | +---Release | dip2_1.exe DIP2_1\main.go 打包的程序 | \---Utils Example.go 包含两个例子和实验图像的原图 fyneExtent.go gui 框架的扩展 ImageCompare.go 编写了图像质量评估的几个方法 ImageProcess.go 图像处理(主要是写了插值算法) Pgm.go Pgm 的读写函数和相关方法 ``` ### 关于实验用例 ```go // 实验用例定义在文件 [Utils\Example.go] 中 // 定义新的用例参考三个 example 函数定义 // 定义用例完成后在 [DIP2_1\main.go] 中使用如下定义加入到选项中 // 这里仅定义下拉框中的值,可以随便命名,但是顺序和 imageExamples 是一致的 var imgs = []string{ "src pgm", "myexample1", "myexample2", } var currentImage = 0 // 默认选中用例的序号 var imageExamples = []func() Utils.PgmFile{ Utils.ZyExample, Utils.MyExample1, Utils.MyExample2, } ``` ### 关于插值算法 ```go // 插值算法定义在文件 [Utils\ImageProcess.go] 中 // 定义新的用例参考三个 interpolation_xxxx 函数定义,格式如下 var interpolation_method func(/* 计算出来的 坐标 */float64,float64, /* xy 偏移 */int,int, /* 源图片大小 */int,int, /* 源图像 */[]byte) (byte,bool) // 这里的偏移是因为旋转的时候是按图像中心旋转,因此偏移量为 (image.width/2,image.height/2),最后下取整 // 新的插值函数定义完成后,需要在 InterpolationMethods 中声明 var InterpolationMethods = []string {"Nearest Neighbor","Bilinear","Bicubic","新定义的方法名"} // 然后在 RotaGrayImage 函数中加入选择分支 if method == InterpolationMethods[0] { interpolation_method = interpolation_nearest } else if method == InterpolationMethods[1] { interpolation_method = interpolation_bilinear } else if method == InterpolationMethods[2] { interpolation_method = interpolation_bicubic } else if method == InterpolationMethods[3] { // 新定义的方法名 interpolation_method = 新定义的方法 } ``` ### 关于图像评估函数 ```go // 图像评估函数定义在文件 [Utils\ImageCompare.go] 中 // 理论上格式可以随意定义,例如 func MSE(img1, img2 []float64) {} // 这里值定义了 MSE,RMSE,PSNR,SSIM // MSSSIM 好像有问题 // 这些函数是根据 GitHub 代码 [https://github.com/andrewekhalel/sewar] 进行复写的 // 因为部分函数用到 opencv 和 numpy,因此不打算复写 ``` ### 参考内容 - [golang GUI 框架 fyne](https://github.com/fyne-io/fyne) - [fyne GUI 看云文档](https://www.kancloud.cn/idcpj/python/1066862) - [比较两幅图像的相似度的各种相似度量对比](https://zhuanlan.zhihu.com/p/402013872) - [[PYTHON] Sewar is a python package for image quality assessment using different metrics](https://github.com/andrewekhalel/sewar) - [MSE 百度百科](https://baike.baidu.com/item/MSE/13845663) - [PSNR 百度百科](https://baike.baidu.com/item/psnr) - [SSIM 百度百科](https://baike.baidu.com/item/SSIM) - [图像插值算法总结](https://www.cnblogs.com/laozhanghahaha/p/12580822.html) - [正确的实现图像旋转](https://zhuanlan.zhihu.com/p/109099445) - [Cubic interpolation](https://www.paulinternet.nl/?page=bicubic) - [图像处理之插值运算](https://blog.csdn.net/lz0499/article/details/69791572) - [Nearest neighbor interpolation, bilinear interpolation and bicubic interpolation realize image zooming, zooming and rotation with MATLAB](https://www.fatalerrors.org/a/0N530zo.html) ### 截图 - 主界面 ![主界面](./pic/main.jpg) - 用例 ![用例](./pic/example.jpg)