summaryrefslogtreecommitdiff
path: root/doc/project-report.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/project-report.md')
-rw-r--r--doc/project-report.md134
1 files changed, 128 insertions, 6 deletions
diff --git a/doc/project-report.md b/doc/project-report.md
index e0339d6..e48c204 100644
--- a/doc/project-report.md
+++ b/doc/project-report.md
@@ -1,30 +1,152 @@
1--- 1---
2title: "Morphing in C" 2title: "BSc IN S5 / Advanced C programming / Morphing"
3author: [Pacien TRAN-GIRARD, Adam NAILI] 3author: [Pacien TRAN-GIRARD, Adam NAILI]
4date: 2017-11-09 4date: 2017-12-28
5... 5...
6 6
7# Project description 7# Project description
8 8
9The goal of this project is to develop a graphical application capable of generating morphing animations given two
10images and constraint parameters.
11
12Being part of the "Advanced C programming" course at [UPEM](http://www.u-pem.fr/), this application has been entirely
13written in C and makes use of the C standard library and the university's graphical application wrapper library.
14
9## Licensing 15## Licensing
10 16
17This work is licensed under the terms of the
18[Creative Commons BY-NC-SA 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/) by its authors:
19Pacien TRAN-GIRARD and Adam NAILI.
20
21Build-time and run-time dependencies of this program are licensed under their own respective terms.
22
11## Credits 23## Credits
12 24
13--- 25This report has been generated using the [Eisvogel template](https://github.com/Wandmalfarbe/pandoc-latex-template),
26licensed under the BSD 3-Clause License.
27
28\newpage
14 29
15# Compilation and usage 30# Compilation and usage
16 31
17## Building the project 32## Building the project
18 33
34The different parts of the project can be built using the make targets listed in `topics/Build.txt`.
35
36Compilation of the program requires gcc (>=6.3), libc (>=2.24) and libMLV (=2.0.2).
37
38Natural Docs (=1.51) and Pandoc are needed to generate the HTML API documentation and the project PDF report
39respectively.
40
41The whole build process has been tested and is known to work on Debian 9.
42
19## Running the program 43## Running the program
20 44
21--- 45The executable binary file resulting from the compilation of the project accepts two arguments: the base and the target
46images. Accepted file formats are ICO, CUR, BMP, PNM, XPM, LBM, PCX, GIF, JPEG, PNG, TGA, TIFF, and XV. Both base and
47target images must have the same dimension.
48
49The graphical interface of the application lets the user define constraint points on the two images, as well as define
50parameters such as the number of desired frames and visualise the morphing animation.
51
52The program has been tested on Debian 9 and is known to run correctly on this platform.
53
54## Additional features
55
56The program supports pairs of pictures of variable sizes.
57
58It also offers the possibility to save morphing animations in GIF format.
59
60## Bugs
61
62Incorrect Delaunay triangulations may be generated with large images of 10k² pixels or more, due to possible 64-bits
63integer overflows during the computation of such triangulations.
64
65Known bugs in the MLV library may prevent the graphical user interface from working correctly on Windows and MacOS.
66
67\newpage
22 68
23# Implementation details 69# Implementation details
24 70
71## Considerations
72
73### API and documentation
74
75Auxiliary functions have been kept module-private to avoid context pollution in the absence of namespaces.
76Exported functions and data types have been prefixed and documented properly.
77
78Natural Docs has been selected as the documentation generator for this projects for its simplicity.
79
80Some MLV library functions have been partly wrapped to ensure the coherence with the internally defined types.
81
82### Unit testing
83
84_"Sir, the testing?"_, Caroline reminds.
85Almost all utility, logic and mathematical functions have been covered by automatic unit tests to reduce the risk of
86small-but-yet-critical mistakes and regressions during the development. Graphical unit tests requiring human validation
87have also been written in order to test the graphical user interface at the component level.
88
89Assertions have also been used within the module implementations, enforcing pre- and post-conditions inside functions.
90
25## Modules 91## Modules
26 92
27## Additional features 93The application has been broken down into several sub-modules, each of which responsible for a well-defined and
94semantically related set of tasks, with little or no coupling between each of those parts.
95
96Following an object-oriented-like paradigm, APIs of said modules are centered around struct data type.
97Furthermore, the number of exposed functions has been kept minimal to ensure the containment of the implementations.
98
99The development of the underlying logic and the graphical interface has been delegated respectively to Pacien and Adam.
100
101\newpage
102
103### Common
104
105The common module contains utility functions for memory management and error handling, as well as common generic
106geometric and time type definitions meant to be used by the other modules, while not being semantically tied to them.
107
108### Morpher
109
110The morpher module holds the type definitions and functions related to a morphing, that is an abstract set of mapping
111constraints represented as a triangulation of a rectangle.
112
113The underlying triangulation maintains the Delaunay criteria and the positive orientation of the triangle vertices in
114the decreasing-y plane throughout the addition of new constraint point mappings.
115
116A neighbourhood graph and a linked list of those subsections are also kept up to date, respectively allowing a faster
117triangle lookup from arbitrarily given coordinates and a simple way of traversing all the triangles.
118
119### Painter
120
121The painter module provides functions to apply a previously constructed morphing to a base and a target image,
122generating a morphed image as the output.
123
124A per-triangle rasterisation algorithm has been implemented instead of the suggested per-pixel triangle lookup for
125performance reasons, as the whole process was meant to run in a single thread on the CPU, not benefiting the massive
126parallelisation possibility that a GPU would have offered.
127
128The colour of each pixel resulting from the rasterisation is interpolated taking care of the compression applied to the
129RBGa vectors from the two base images: each component is square-rooted back to its raw value before blending.
130
131### GUI
132
133TODO: modular component-based architecture, wrapping libMLV low level functions\
134 based on delegated click handlers and painting functions\
135 computing intermediate morphing between each frame, combined with a times, thus not using MLV_Animation
136
137\newpage
138
139## Miscellaneous notes
140
141The animation export feature relies on the MLV library for exporting the frames and ImageMagick for generating the final
142animated GIF. This utility library is called as an external command line tool as its direct use as a C library was not
143permitted.
28 144
29## Notes 145# References
30 146
1471. [MLV Library reference manual](http://www-igm.univ-mlv.fr/~boussica/mlv/api/French/html/index.html), A. Boussicault and M. Zipstein, September 2015
1481. [Natural Docs 1.x reference manual](https://web.archive.org/web/20170504223714/http://www.naturaldocs.org:80/documenting/reference.html), Greg Valure, May 2017
1491. [Barycentric coordinate system](https://en.wikipedia.org/w/index.php?title=Barycentric_coordinate_system&oldid=816475141), Wikipedia contributors, December 2017
1501. [Delaunay triangulation](https://en.wikipedia.org/w/index.php?title=Delaunay_triangulation&oldid=817290072), Wikipedia contributors, December 2017
1511. [Computer Color is Broken](https://www.youtube.com/watch?v=LKnqECcg6Gw), Minute Physics, March 2015
1521. [Software Rasterization Algorithms for Filling Triangles](http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html), Sunshine, May 2012