Task 080: Triangle-mesh warping

You should implement image warping defined by two triangle meshes. There are two triangle meshes with shared topology, the first one covers the source image, the second one covers the target space. User is able to edit both meshes interactively. After every change image warping procedure is executed and the target image is altered.



Two triangle meshes have the same topology, so for every triangle Si in the source space there is a corresponding one Ti in the target space. Raster image transform is naturally transferring every point of the source triangle Si to the corresponding point of the target triangle Ti. Use Barycentric coordinates for the actual point-to-point mapping. As both canonic and barycentric coordinates are linear, you can derive simple scanline warping algorithm using finite differences.


You have to use the 080warping project from the grcis repository. Simple WinForms-based application is ready, you need only to implement proper image transformation in the function Warping.Warp().

Application is able to load new image, to [re]set triangle mesh density and to save result image to a disk file. User is able drag vertices on both source and target images using left mouse button. After each drag procedure is finished (left mouse button is up), your Warping.Warp() function is called and the target image is recomputed.


The function Warping.Warp() is called only in the Warping instance of the target image. Thus it needs a source image (argument sourceimage) and a source mesh object (argument sourceMesh). A new instance of the Bitmap object should be created and returned as a result. If you are capable of implementing fast Bitmap access (via Bitmal.LockBits()), please do so. But this is optional.

Two more tasks: you should handle correctly every vertex-relocation in the Warping.MoveVertex() function. Now there are no checks, you should avoid moving a vertex outside the image region and moving border vertex out of the border. Further improvements are optional - avoiding edge crossings, etc.


Source file Warping.cs.
Your name in the comment on the first line.
Declare which optional tasks you did implement (fast Bitmap access, edge-crossing check..).


Due to: 12. 11. 2017


Base: 20 points (functional image warping), bonus points for optional tasks (fast Bitmap access, edge-crossing check..)


Visual Studio project: 080warping.

Source file

Modify and submit the file: Warping.cs

Copyright (C) 2015-2017 J.Pelikán, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)