Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中,实现像photoshop那样的液化过滤器最基本的方法是什么?_Java_Image Processing_Filter_Image Manipulation_Morphing - Fatal编程技术网

在java中,实现像photoshop那样的液化过滤器最基本的方法是什么?

在java中,实现像photoshop那样的液化过滤器最基本的方法是什么?,java,image-processing,filter,image-manipulation,morphing,Java,Image Processing,Filter,Image Manipulation,Morphing,在java中,实现像photoshop那样的液化过滤器最基本的方法是什么?基本上,您有一个源图像和一个网格。网格从带有完美正方形的栅格开始,但会变形。算法是 For Each section of the mesh For Each pixel of the section (x, y) = Location in original photo for this pixel // (floating point) color = ColorFro

在java中,实现像photoshop那样的液化过滤器最基本的方法是什么?

基本上,您有一个源图像和一个网格。网格从带有完美正方形的栅格开始,但会变形。算法是

  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)
算出(x,y)是一个简单的几何图形——将变形正方形的中心映射到原始三角形的中心,然后算出所处的三角形(N,S,E,W),并将变形三角形映射到原始三角形

  +---------+
  |\       /|
  | \  N  / |
  |  \   /  |
  |   \ /   |
  | W  X  E |
  |   / \   |
  |  /   \  |
  | /  S  \ |
  |/       \|
  +---------+
一旦(x,y)为浮点,通过混合与该浮点重叠的四个像素来计算其颜色。以重叠的比率进行坐标

整数像素

   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
浮动pt。覆盖在上面的像素

   +----+----+----+
   |    |    |    |
   |   x|xx  |    |
   +----+----+----+
   |   x|xx  |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
结果颜色是四个像素按重叠程度的比例混合


这正是调整大小(重采样)的算法——网格没有变形,只是放大了,所以三角形步骤是不必要的,但这是相同的想法

您要找的基本上是一个扭曲过滤器,您可以查看:我猜您要找的是


希望这有助于偷它。或者,研究图像处理,直到你知道它有多复杂,然后实现它。我最终会研究图像处理,但它有点紧急,所以你知道在哪里(如何)偷它吗?