Create Anaglyph (GIMP Plugin)
doc.py
Go to the documentation of this file.
1 ##
2 # \mainpage Introduction
3 # The anaglyph Generator generates a stereoscopic anaglyph image from a given
4 # layered gray level image. Every layer is assigned a specific depth.
5 # This information is then utilized to generate the stereoscopic image.
6 # * \ref page_usage
7 # * \ref page_installation
8 # * Software \ref page_architecture (maintenance)
9 #
10 # ### Example input/output
11 # \image html demo500.png left: input image, all layers merged. right: generated anaglyph (you need red/cyan glasses)
12 #
13 # ### Used software:
14 # * http://www.gimp.org, the drawing application "The GIMP".
15 # * http://www.python.org to write the software (a GIMP plugin).
16 # * http://www.numpy.org (python lib) for simple signal/array processing.
17 # * http://de.plantuml.com/ to generate UML images.
18 # * http://www.arc42.org/ software architecture structure.
19 # * http://www.doxygen.org/ to generate the documentation.
20 #
21 #
22 # \page page_usage Usage
23 # The plugin is visible in the menu "Filters/Goto 40/Create Anaglyph From Layers".
24 #
25 # ### Parameters and simple layer usage
26 # The plugin has the following parameters:
27 # * "min disparity, percent width (near)":
28 # * minimum disparity (shift between left and right, generates depth perception)
29 # * 0 = no depth (screen)
30 # * <0 = between user and screen
31 # * >0 = behind screen
32 # * "max disparity, percent width (far)":
33 # * like min. disparity (should be > min. disparity)
34 # * "luminance correction left (0.0..1.0)":
35 # * 1.0 = no correction; <1.0 darkens left image
36 # * "luminance correction right (0.0..1.0)":
37 # * 1.0 = no correction; <1.0 darkens right image
38 # * "swap left/right":
39 # * normally "no"
40 # * "yes" swaps left and right image (you swap the left and right side of your glasses)
41 #
42 # Image and layer properties:
43 # * Only gray level images with and alpha channel can be used.
44 # * All layers must have the full image size.
45 # * All layers must have no layer mask (apply before use).
46 # * The order of layers is used as depth (most visible layer is nearest).
47 #
48 # ### Special layer properties
49 # * Layers named "depthmap <name> <float> to <float>" are ignored. They define depth maps with a given value range, which can be used as depth info for other layers.
50 # * The name of the layer can overwrite the depth deduced from the layer order:
51 # * "background" : a layer without disparity (typically colored in one color).
52 # * "depth=<float>" : fixed depth of this layer (0.0=nearest layer, 1.0=farthest layer).
53 # * "reldepthmap <name>" : use depth map (is scaled such that the range 0.0 to 1.0 fits the space between two layers).
54 # * "fixdepthmap <name>" : use depth map with fixed depths.
55 #
56 # Important note when using depthmaps:
57 # * Depth is stimulated through an artifical disparity (a shift between left and right image).
58 # * The depthmaps specify this shift for every pixel.
59 # * However, the depthmaps are used to determine where a pixel comes from and not where it goes to. Thus, a depth map region must be wider than the object is is meant for. Also it may yield strange effects when it as abrupt changes (discontinuities). Best, is to use smooth depth maps, ideally representing a vertical gradient (constant from left to right).
60 #
61 # \image html depthmaps500.png images generated with depthmaps (you need red/cyan glasses)
62 # \image html depthmaps500_expl.png left: gimp screenshot demonstrating the usage of depth maps; right: example depthmap
63 #
64 # ### Observations / open points
65 # * JPG compression seems to destroy the stereoscopic effect in some cases (artifacts or color corruption?).
66 # * On my screen, with my glasses, with my eyes it is helpful to darken the cyan image.
67 #
68 # \page page_installation Installation
69 # You need numpy to execute the plugin (e.g., apt-get install numpy).
70 # You need to put the plugin code in the gimp plugin search path (e.g. see "Edit/Preferences/Folders/Plug-Ins").
71 #
72 # \page page_architecture Architecture
73 # This page describes the architecture of the software. It helps modifying and maintaining the software. It also demonstrates how to combine numpy (or scipy) with gimp (gimpfu_numpy_converter.py).
74 #
75 # ### Goal
76 # Create a tool to generate anaglyphs from (scanned) flat images arranged in depth.
77 #
78 # ### Constraints
79 # The selected solution has the following constraints: Plugins must be written in python or scheme.
80 #
81 # ### Context
82 # The context of the plugin is gimp (who owns/calls the plugin)
83 # and additional required libraries for signal/image processing.
84 #
85 # ### Solution
86 # * Real 3D renderer (blender, povray) were considered to be too complex to use for this task.
87 # * A gimp plugin seemed to be a possible solution.
88 # * It allows easy composition of scanned images.
89 # * It also allows to scan and pre process the images.
90 #
91 # ### Building Block View
92 # The context of the plugin is gimp (who owns/calls the plugin)
93 # and additional required libraries.
94 # The plugin itself is organized as follows:
95 # * Module create_anaglyph_plugin.py (component "Plugin"): The main plugin code (control code)
96 # * Module anaglyph_algorithm.py (component "anaglyph_algorithm", class anaglyph_algorithm.Anaglyph): the core algorithm
97 # * Module depth_algorithm.py (component "depth_algorithm", class depth_algorithm.DepthAlgo): functions to determine a layers depth
98 # * Module gimpfu_numpy_converter.py (component "gimpfu_numpy_converter"): functions to convert from/to gimpfu data structures to/from numpy arrays.
99 # \startuml
100 # node "Create Anaglyph Plugin" {
101 # component [anaglyph_algorithm] #Cyan
102 # component [depth_algorithm] #LightBlue
103 # component [gimpfu_numpy_converter] #LightGreen
104 # [Plugin] ..> [gimpfu_numpy_converter] : use
105 # [Plugin] ..> [anaglyph_algorithm] : use
106 # [Plugin] ..> [depth_algorithm] : use
107 # }
108 # [gimpfu_numpy_converter] ..> [numpy] :use
109 # [gimpfu_numpy_converter] ..> [gimpfu] :use
110 # [anaglyph_algorithm] ..> [numpy] :use
111 # [anaglyph_algorithm] ..> [gimpfu] :use
112 # [depth_algorithm] ..> [numpy] :use
113 # [depth_algorithm] ..> [gimpfu] :use
114 # [gimp] ..> [Plugin] :calls
115 # \enduml
116 #
117 # ###Runtime View
118 # Here we sketch the activities executed by the plugin (create_anaglyph_plugin.run). The colors match the components
119 # corresponding to the described modules above.
120 # \startuml
121 # start
122 # if (check input format and parameters) then (ok)
123 # #Cyan:init algorithm output (numpy);
124 # while(for each layer of the input image)
125 # #LightBlue:determine depth of layer;
126 # note left
127 # The depth is influenced by the parameters
128 # (e.g. min/max disparity). The depth can be
129 # extracted from the layers' name (keyword
130 # based) or from the natural layer order.
131 # end note
132 # #LightGreen:convert layer data to numpy array;
133 # #Cyan:update algorithm output (numpy);
134 # note left
135 # The algorithm needs the layers gray
136 # level image representation and the
137 # alpha channel.
138 # end note
139 # :update progress bar;
140 # endwhile
141 # :create new image with algorithm output;
142 # #LightGreen:convert algorithm output array (numpy) to gimp data;
143 # :display output (gimp);
144 # else (not ok)
145 # :error message;
146 # note right
147 # parameter checking
148 # is not implemented.
149 # end note
150 # endif
151 # end
152 # \enduml
153 #
154 # ###Deployment View:
155 # (see \ref page_installation)
156 #
157 # ###Concepts
158 # * Data is converted from the gimp format to numpy and back.
159 # * Algorithms process on numpy arrays.
160 #
161