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