What is the most basic approach to implementing a liquefaction filter, as in one Photoshop, in java?

What is the most basic approach for implementing a liquefaction filter, like in one Photoshop, in java?

+3
source share
2 answers

Basically, you have the original image and the grid. The grid begins as a grid with perfect squares, but is deformed. Algorithm

  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)

Finding out (x, y) - simple geometry - match the center of the deformed square to the center of the original, then determine which triangle you are (N, S, E, W) and the deformed triangle to the original.

  +---------+
  |\       /|
  | \  N  / |
  |  \   /  |
  |   \ /   |
  | W  X  E |
  |   / \   |
  |  /   \  |
  | /  S  \ |
  |/       \|
  +---------+

(x, y) , , , pt. .

   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+

pt. ,

   +----+----+----+
   |    |    |    |
   |   x|xx  |    |
   +----+----+----+
   |   x|xx  |    |
   |    |    |    |
   +----+----+----+
   |    |    |    |
   |    |    |    |
   +----+----+----+

- , .

(resample). , , , .

+5

Source: https://habr.com/ru/post/1769965/


All Articles