Morphing Algorithms


Up

The morphing algorithm is defined using the parameters MODE and DEPTH to MPRender.

The basic algorithm is to find 3 points which make a triangle around the point and morph this triangle between the start and end images.

The DEPTH parameter controls how many points will be checked to form a triangle. 0 means just the closest 3 points are examined, 1 the closest 4, 2 the closest 5 etc.

The MODE parameter controls both which triangle is chosen and what to do if no surrounding triangle is found.

If MODE=0 2 4 ... 14 (i.e. bit 1 not set [do not add 1]) then if no triangle surrounding the point is found examining the closest points then the 3 closest points are used to decide how to morph. Otherwise the point is assumed to be stationery.

If MODE=2 3 4 ... 15 (i.e. bit 2 set [add 2]) then the closest triangles are only calculated once at the start (based on the average of start and end). This should only be used if the points do not move a lot between the start and end images. It can speed things up a lot for a lot of frames. It does not make sense to use this for Animated Warps/Morphs. This uses a lot of memory:

If MODE=2 3 6 7 ... 30 31 (i.e. bit 2 set [add 2]) then all the closest points (the exact number controlled by DEPTH) are examined to determine the smallest triangle. Otherwise the first surrounding triangle found is used.

If MODE=8 9 10 ... (i.e. bit 4 set [add 8]) then a Delauany triangle algorithm is used to find triangles. For these modes the DEPTH parameter should normally be set to 0. Also floating point calculations are still done even if INTEGER is set to YES.

Setting precalculate can use a lot of memory. e.g.

    (DEPTH + 4) * Image_Width * Image_Height * 4

    e.g. 640x512 image, DEPTH=2 uses 7.5 MB (contiguous) memory

The DEPTH parameter can have a major effect on the rendering speed.