Ton*_*ony 4 java image-manipulation image-processing filter morphing
在java中实现lihopify过滤器的最基本方法是什么?
基本上,你有一个源图像和一个网格.网格以具有完美正方形的网格开始,但变形.算法是
For Each section of the mesh
For Each pixel of the section
(x, y) = Location in original photo for this pixel // (floating point)
color = ColorFromOriginal(x, y) // this needs to blend neighboring pixels if fractional
setColor(color)
Run Code Online (Sandbox Code Playgroud)
确定(x,y)是简单的几何 - 将变形的正方形的中心映射到原始的中心,然后找出你所在的三角形(N,S,E,W)并将变形的三角形映射到原本的.
+---------+
|\ /|
| \ N / |
| \ / |
| \ / |
| W X E |
| / \ |
| / \ |
| / S \ |
|/ \|
+---------+
Run Code Online (Sandbox Code Playgroud)
一旦你有(x,y)浮点,通过混合浮动pt重叠的四个像素来计算它的颜色.坐标重叠的比例.
整数像素
+----+----+----+
| | | |
| | | |
+----+----+----+
| | | |
| | | |
+----+----+----+
| | | |
| | | |
+----+----+----+
Run Code Online (Sandbox Code Playgroud)
浮动角 像素覆盖在它上面
+----+----+----+
| | | |
| x|xx | |
+----+----+----+
| x|xx | |
| | | |
+----+----+----+
| | | |
| | | |
+----+----+----+
Run Code Online (Sandbox Code Playgroud)
结果颜色是四个像素的重叠比例.
这正是调整大小(重新采样)的算法 - 网格没有变形,只是放大了,所以三角形步骤是不必要的,但它是相同的想法.
您正在寻找的基本上是一个warp过滤器,您可以查看:http://www.jhlabs.com/ip/filters/ 我想您正在寻找的是http://www.jhlabs.com/ip /filters/WarpFilter.html
希望有所帮助
| 归档时间: |
|
| 查看次数: |
2255 次 |
| 最近记录: |