灰度插值实验
2016-05-05 15:26
155 查看
灰度插值实验
才疏学浅,资历欠佳,难免有误,望有心人批评指正。
本文旨在展示绘图插值最近邻插值
Clear[T, img, mat, row, col, mat2, x, y, x2, y2, v, v2, img2]; \[Theta] = 30 Degree; sin = Sin[\[Theta]] // N; cos = Cos[\[Theta]] // N; T = {{cos, -sin, 0}, {sin, cos, 0}, {0, 0, 1}}; (*T={{2,0,0},{0,1,0},{0,0,1}};*) iT = Inverse[T]; img = Import["lena_gray_256.tif", "TIFF"]; mat = ImageData[img, "Byte"]; {row, col} = Dimensions[mat]; mat2 = Table[0, {row}, {col}]; For[y = 1, y <= row, y++, For[x = 1, x <= col, x++, v = {x, y, 1}; v2 = iT.v;(*点积*){x2, y2, t} = Round[v2];(*最近邻*) If[1 <= x2 <= col && 1 <= y2 <= row, mat2[[y, x]] = mat[[y2, x2]] ] ]; ]; img2 = Image[mat2, "Byte"]; GraphicsRow[{img, img2}, ImageSize -> Medium]
双线性插值
affine[img_, T_] := Module[{iT, mat, row, col, mat2, x, y, v2, p, x2, y2, p0, x0, y0, u, v, f, f1, f2, img2}, iT = Inverse[T]; mat = ImageData
[img]http://img.blog.csdn.net/20160505152517818" border="0" >
相关文章推荐
- 二十四 多重继承
- 在IE中检查控件是否安装成功
- Django笔记:5.激活模型
- ali面试点滴
- C++泛型编程
- #动态加载#OnscrollListener
- 用J-Link烧写bootloader到Mini2440的Nor Flash
- PowerDesigner15的安装和破解
- 重新部署shop++项目重复安装去除。
- php对接java现实加签验签
- SQL 左外连接,右外连接,全连接,内连接
- 设计模式之Strategy模式(策略模式)
- Java并发编程:如何创建线程?
- CSS中单位px和em,rem的区别
- gRPC java 客户端,服务器端通讯使用json格式
- 三体 读后感
- sqlite、mysql 将时间戳转换成本地时间语句
- SQL Server 维护计划实现数据库备份(Step by Step)(转)
- Markdown 使用
- 云智巡能否提高运营决策能力?