Debian Codegraph @

doc/features/image/menu_operations.rst

raw
1 .. _ima-menu-operations:
2
3 Operations on Images
4 ====================
5
6 This section describes the operations that can be performed on images.
7
8 .. seealso::
9
10 :ref:`ima-menu-processing` for more information on image processing features,
11 or :ref:`ima-menu-analysis` for information on analysis features on images.
12
13 .. figure:: /images/shots/i_operation.png
14
15 Screenshot of the "Operations" menu.
16
17 When the "Image Panel" is selected, the menus and toolbars are updated to
18 provide image-related actions.
19
20 The "Operations" menu allows you to perform various operations on the current
21 image or group of images. It also allows you to extract profiles, distribute
22 images on a grid, or resize images.
23
24 Operations with a constant
25 --------------------------
26
27 Create a new image which is the result of a constant operation on each selected image:
28
29 .. list-table::
30 :header-rows: 1
31 :widths: 25, 75
32
33 * - Operation
34 - Equation
35 * - |constant_add| Add
36 - :math:`z_{k} = z_{k-1} + conv(c)`
37 * - |constant_subtract| Subtract
38 - :math:`z_{k} = z_{k-1} - conv(c)`
39 * - |constant_multiply| Multiply
40 - :math:`z_{k} = conv(z_{k-1} \times c)`
41 * - |constant_divide| Divide
42 - :math:`z_{k} = conv(\dfrac{z_{k-1}}{c})`
43
44 .. |constant_add| image:: ../../../datalab/data/icons/operations/constant_add.svg
45 :width: 24px
46 :height: 24px
47 :class: dark-light no-scaled-link
48
49 .. |constant_subtract| image:: ../../../datalab/data/icons/operations/constant_subtract.svg
50 :width: 24px
51 :height: 24px
52 :class: dark-light no-scaled-link
53
54 .. |constant_multiply| image:: ../../../datalab/data/icons/operations/constant_multiply.svg
55 :width: 24px
56 :height: 24px
57 :class: dark-light no-scaled-link
58
59 .. |constant_divide| image:: ../../../datalab/data/icons/operations/constant_divide.svg
60 :width: 24px
61 :height: 24px
62 :class: dark-light no-scaled-link
63
64 where :math:`c` is the constant value and :math:`conv` is the conversion function
65 which handles data type conversion (keeping the same data type as the input image).
66
67 Basic arithmetic operations
68 ---------------------------
69 Arithmetic operations are performed pixel by pixel between the selected images.
70
71 .. list-table::
72 :header-rows: 1
73 :widths: 40, 60
74
75 * - Operation
76 - Description
77 * - |sum| Sum
78 - :math:`z_{M} = \sum_{k=0}^{M-1}{z_{k}}`
79 * - |difference| Difference
80 - :math:`z_{2} = z_{1} - z_{0}`
81 * - |product| Product
82 - :math:`z_{M} = \prod_{k=0}^{M-1}{z_{k}}`
83 * - |division| Division
84 - :math:`z_{2} = \dfrac{z_{1}}{z_{0}}`
85 * - |inverse| Inverse
86 - :math:`z_{2} = \dfrac{1}{z_{1}}`
87 * - |exponential| Exponential
88 - :math:`z_{2} = \exp(z_{1})`
89 * - |logarithm| Logarithm (base 10)
90 - :math:`z_{2} = \log_{10}(z_{1})`
91
92
93 .. |sum| image:: ../../../datalab/data/icons/operations/sum.svg
94 :width: 24px
95 :height: 24px
96 :class: dark-light no-scaled-link
97
98
99 .. |difference| image:: ../../../datalab/data/icons/operations/difference.svg
100 :width: 24px
101 :height: 24px
102 :class: dark-light no-scaled-link
103
104 .. |product| image:: ../../../datalab/data/icons/operations/product.svg
105 :width: 24px
106 :height: 24px
107 :class: dark-light no-scaled-link
108
109 .. |division| image:: ../../../datalab/data/icons/operations/division.svg
110 :width: 24px
111 :height: 24px
112 :class: dark-light no-scaled-link
113
114 .. |inverse| image:: ../../../datalab/data/icons/operations/inverse.svg
115 :width: 24px
116 :height: 24px
117 :class: dark-light no-scaled-link
118
119 .. |exponential| image:: ../../../datalab/data/icons/operations/exp.svg
120 :width: 24px
121 :height: 24px
122 :class: dark-light no-scaled-link
123
124 .. |logarithm| image:: ../../../datalab/data/icons/operations/log10.svg
125 :width: 24px
126 :height: 24px
127 :class: dark-light no-scaled-link
128
129
130
131
132 Basic mathematical functions
133 ----------------------------
134
135 .. list-table::
136 :header-rows: 1
137 :widths: 40, 60
138
139 * - Function
140 - Description
141 * - |exp| Exponential
142 - :math:`z_{k} = \exp(z_{k})`
143 * - |log10| Logarithm (base 10)
144 - :math:`z_{k} = \log_{10}(z_{k})`
145 * - Log10(z+10)
146 - :math:`z_{k} = \log_{10}(z_{k}+n)` (useful if image background is zero)
147
148 .. |exp| image:: ../../../datalab/data/icons/operations/exp.svg
149 :width: 24px
150 :height: 24px
151 :class: dark-light no-scaled-link
152
153 .. |log10| image:: ../../../datalab/data/icons/operations/log10.svg
154 :width: 24px
155 :height: 24px
156 :class: dark-light no-scaled-link
157
158 Convolution and Deconvolution
159 ------------------------------
160
161 .. list-table::
162 :header-rows: 1
163 :widths: 40, 60
164
165 * - Operation
166 - Implementation
167 * - |convolution| Convolution
168 - Based on `scipy.signal.convolve <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve.html>`_
169 * - |deconvolution| Deconvolution
170 - Frequency domain deconvolution
171
172
173 .. |convolution| image:: ../../../datalab/data/icons/operations/convolution.svg
174 :width: 24px
175 :height: 24px
176 :class: dark-light no-scaled-link
177
178 .. |deconvolution| image:: ../../../datalab/data/icons/operations/deconvolution.svg
179 :width: 24px
180 :height: 24px
181 :class: dark-light no-scaled-link
182
183 Absolute value and complex image operations
184 -------------------------------------------
185
186 .. list-table::
187 :header-rows: 1
188 :widths: 40, 60
189
190 * - Operation
191 - Description
192 * - |abs| Absolute value
193 - :math:`z_{k} = |z_{k-1}|`
194 * - |phase| Phase (argument)
195 - :py:func:`sigima.proc.image.phase`
196 * - |complex_from_magnitude_phase| Combine with phase
197 - Consider current image as the module and allow to select a image
198 representing the phase to merge them in a complex image
199 :py:func:`sigima.proc.image.complex_from_magnitude_phase`
200 * - |re| Real part
201 - :math:`z_{k} = \Re(z_{k-1})`
202 * - |im| Imaginary part
203 - :math:`z_{k} = \Im(z_{k-1})`
204 * - |complex_from_real_imag| Combine with imaginary part
205 - Consider current image as the real part and allow to select a image
206 representing the imaginary part to merge them in a complex image
207 :py:func:`sigima.proc.image.complex_from_real_imag`
208
209
210 .. |abs| image:: ../../../datalab/data/icons/operations/abs.svg
211 :width: 24px
212 :height: 24px
213 :class: dark-light no-scaled-link
214
215 .. |phase| image:: ../../../datalab/data/icons/operations/phase.svg
216 :width: 24px
217 :height: 24px
218 :class: dark-light no-scaled-link
219
220 .. |complex_from_magnitude_phase| image:: ../../../datalab/data/icons/operations/phase.svg
221 :width: 24px
222 :height: 24px
223 :class: dark-light no-scaled-link
224
225 .. |re| image:: ../../../datalab/data/icons/operations/re.svg
226 :width: 24px
227 :height: 24px
228 :class: dark-light no-scaled-link
229
230 .. |im| image:: ../../../datalab/data/icons/operations/im.svg
231 :width: 24px
232 :height: 24px
233 :class: dark-light no-scaled-link
234
235 .. |complex_from_real_imag| image:: ../../../datalab/data/icons/operations/im.svg
236 :width: 24px
237 :height: 24px
238 :class: dark-light no-scaled-link
239
240
241 Data type conversion
242 --------------------
243
244 The "Convert data type" |convert_dtype| action allows you to convert the data type
245 of the selected images. For integer data types, the conversion is done by clipping
246 the values to the new data type range before effectively converting the data type.
247 For floating point data types, the conversion is straightforward.
248
249 .. |convert_dtype| image:: ../../../datalab/data/icons/operations/convert_dtype.svg
250 :width: 24px
251 :height: 24px
252 :class: dark-light no-scaled-link
253
254 .. note::
255
256 Data type conversion uses the :py:func:`sigima.tools.datatypes.clip_astype`
257 function which relies on :py:func:`numpy.ndarray.astype` function with
258 the default parameters (`casting='unsafe'`).
259
260 Statistics between images
261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
262 Create a new image which is the result of a statistical operation on each pixel of the selected images:
263
264 .. list-table::
265 :header-rows: 1
266 :widths: 40, 60
267
268 * - Operation
269 - Description
270 * - |average| Average
271 - :math:`z_{M} = \dfrac{1}{M}\sum_{k=0}^{M-1}{z_{k}}`
272 * - |standard_deviation| Standard Deviation
273 - :math:`z_{M} = \sqrt{\dfrac{1}{M}\sum_{k=0}^{M-1}{(y_{k} - \bar{y})^{2}}}`
274 * - |quadratic_difference| Quadratic difference
275 - :math:`z_{2} = \dfrac{z_{1} - z_{0}}{\sqrt{2}}`
276 .. |average| image:: ../../../datalab/data/icons/operations/average.svg
277 :width: 24px
278 :height: 24px
279 :class: dark-light no-scaled-link
280
281 .. |standard_deviation| image:: ../../../datalab/data/icons/operations/std.svg
282 :width: 24px
283 :height: 24px
284 :class: dark-light no-scaled-link
285
286 .. |quadratic_difference| image:: ../../../datalab/data/icons/operations/quadratic_difference.svg
287 :width: 24px
288 :height: 24px
289 :class: dark-light no-scaled-link
290
291 Flat-field correction
292 ^^^^^^^^^^^^^^^^^^^^^
293
294 Create a new image which is flat-field correction
295 of the **two** selected images:
296
297 .. math::
298 z_{1} =
299 \begin{cases}
300 \dfrac{z_{0}}{z_{f}}.\overline{z_{f}} & \text{if } z_{0} > z_{threshold} \\
301 z_{0} & \text{otherwise}
302 \end{cases}`
303
304 where :math:`z_{0}` is the raw image,
305 :math:`z_{f}` is the flat field image,
306 :math:`z_{threshold}` is an adjustable threshold
307 and :math:`\overline{z_{f}}` is the flat field image average value:
308
309 .. math::
310 \overline{z_{f}}=
311 \dfrac{1}{N_{row}.N_{col}}.\sum_{i=0}^{N_{row}}\sum_{j=0}^{N_{col}}{z_{f}(i,j)}
312
313 .. note::
314
315 Raw image and flat field image are supposedly already
316 corrected by performing a dark frame subtraction.