Debian Codegraph @

doc/features/image/menu_processing.rst

raw
1 .. _ima-menu-processing:
2
3 Processing Images
4 =================
5
6 This section describes the image processing features available in DataLab.
7
8 .. seealso::
9
10 :ref:`ima-menu-operations` for more information on operations that can be performed
11 on images, or :ref:`ima-menu-analysis` for information on analysis features on
12 images.
13
14 .. figure:: /images/shots/i_processing.png
15
16 Screenshot of the "Processing" menu.
17
18 When the "Image Panel" is selected, the menus and toolbars are updated to
19 provide image-related actions.
20
21 The "Processing" menu allows you to perform various processing on the current
22 image or group of images: it allows you to apply filters, to perform exposure
23 correction, to perform denoising, to perform morphological operations, and so on.
24
25 Geometry
26 ^^^^^^^^
27
28 Flip and rotation
29 ~~~~~~~~~~~~~~~~~
30
31 Create a new image by flipping or rotating the data of the selected image.
32 The image may be flipped horizontally, vertically, or diagonally (transposition).
33 It may be rotated by 90°, 270° or any user-defined value.
34
35 .. list-table::
36 :header-rows: 1
37 :widths: 40, 60
38
39 * - Operation
40 - Description
41 * - Flip horizontally
42 - Mirror image along the vertical axis
43 * - Flip diagonally
44 - Transpose the image (swap X/Y axes)
45 * - Flip vertically
46 - Mirror image along the horizontal axis
47 * - Rotate 90° right
48 - Rotate image 90° clockwise
49 * - Rotate 90° left
50 - Rotate image 90° counter-clockwise
51 * - Rotate by...
52 - Rotate image by any angle (user-defined)
53
54 Distribute images along a grid
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
57 .. list-table::
58 :header-rows: 1
59 :widths: 40, 60
60
61 * - Feature
62 - Description
63 * - |distribute_on_grid| Distribute on a grid
64 - Distribute selected images on a regular grid
65 * - |reset_positions| Reset image positions
66 - Reset the positions of the selected images to first image (x0, y0) coordinates
67
68 .. |distribute_on_grid| image:: ../../../datalab/data/icons/processing/distribute_on_grid.svg
69 :width: 24px
70 :height: 24px
71 :class: dark-light no-scaled-link
72
73 .. |reset_positions| image:: ../../../datalab/data/icons/processing/reset_positions.svg
74 :width: 24px
75 :height: 24px
76 :class: dark-light no-scaled-link
77
78 Axis transformation
79 ^^^^^^^^^^^^^^^^^^^
80
81 Set uniform coordinates
82 ~~~~~~~~~~~~~~~~~~~~~~~
83
84 Create a new image with uniform coordinates (i.e., with a constant pixel size in both X and Y directions).
85
86 Polynomial calibration
87 ~~~~~~~~~~~~~~~~~~~~~~
88
89 Create a new image which is a polynomial calibration
90 of each selected image with respect to Z axis.
91
92 .. note::
93
94 Linear calibration was removed from the UI as it is a special case of polynomial calibration with degree 1.
95
96 Level adjustment
97 ^^^^^^^^^^^^^^^^
98
99 Normalize
100 ~~~~~~~~~
101
102 Create a new image which is the normalized version of each selected image
103 by maximum, amplitude, sum, energy or RMS:
104
105 .. list-table::
106 :header-rows: 1
107 :widths: 25, 75
108
109 * - Normalization
110 - Equation
111 * - Maximum
112 - :math:`z_{1} = \dfrac{z_{0}}{z_{\max}}`
113 * - Amplitude
114 - :math:`z_{1} = \dfrac{z_{0}}{z_{\max}-z_{\min}}`
115 * - Area
116 - :math:`z_{1} = \dfrac{z_{0}}{\sum_{i=0}^{N-1}{z_{i}}}`
117 * - Energy
118 - :math:`z_{1}= \dfrac{z_{0}}{\sqrt{\sum_{n=0}^{N}\left|z_{0}[n]\right|^2}}`
119 * - RMS
120 - :math:`z_{1}= \dfrac{z_{0}}{\sqrt{\dfrac{1}{N}\sum_{n=0}^{N}\left|z_{0}[n]\right|^2}}`
121
122 Clipping
123 ~~~~~~~~
124
125 Apply the clipping to each selected image.
126
127 Offset correction
128 ~~~~~~~~~~~~~~~~~
129
130 Create a new image which is the result of offset correction on each selected image.
131 This operation is performed by subtracting the image background value which is estimated
132 by the mean value of a user-defined rectangular area.
133
134 Noise addition
135 ^^^^^^^^^^^^^^
136
137 Generate new images by adding the same noise to each selected image.
138 The available noise types are:
139
140 .. list-table::
141 :header-rows: 1
142 :widths: 25, 75
143
144 * - Noise
145 - Description
146 * - Gaussian
147 - Normal distribution
148 * - Uniform
149 - Uniform distribution
150 * - Poisson
151 - Poisson distribution
152
153 Noise reduction
154 ^^^^^^^^^^^^^^^
155
156 Create a new image which is the result of noise reduction on each selected image.
157
158 The following filters are available:
159
160 .. list-table::
161 :header-rows: 1
162 :widths: 25, 75
163
164 * - Filter
165 - Formula/implementation
166 * - Gaussian filter
167 - `scipy.ndimage.gaussian_filter <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter.html>`_
168 * - Moving average
169 - `scipy.ndimage.uniform_filter <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.uniform_filter.html>`_
170 * - Moving median
171 - `scipy.ndimage.median_filter <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.median_filter.html>`_
172 * - Wiener filter
173 - `scipy.signal.wiener <https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.wiener.html>`_
174
175 Fourier analysis
176 ^^^^^^^^^^^^^^^^
177
178 Zero padding
179 ~~~~~~~~~~~~
180
181 Create a new image which is the result of zero padding on each selected image.
182
183 The following parameters are available:
184
185 .. list-table::
186 :header-rows: 1
187 :widths: 25, 75
188
189 * - Parameter
190 - Description
191 * - Strategy
192 - Zero padding strategy (see below)
193 * - Rows
194 - Number of rows to add (if `strategy` is 'custom')
195 * - Columns
196 - Number of columns to add (if `strategy` is 'custom')
197 * - Position
198 - Position of the added zeros: 'bottom-right', 'centered'
199
200 Zero padding strategy refers to the method used to add zeros to the image, and it can be one of the following:
201
202 .. list-table::
203 :header-rows: 1
204 :widths: 25, 75
205
206 * - Strategy
207 - Description
208 * - next_pow2
209 - Next power of 2 (e.g. 512, 1024, ...)
210 * - multiple_of_64
211 - Next multiple of 64 (e.g. 512, 576, ...)
212 * - custom
213 - Custom size (user-defined)
214
215 FFT related functions
216 ~~~~~~~~~~~~~~~~~~~~~
217
218 Create a new image which is the result of a Fourier analysis on each selected image.
219
220 The following functions are available:
221
222 .. list-table::
223 :header-rows: 1
224 :widths: 20, 30, 50
225
226 * - Function
227 - Description
228 - Formula/implementation
229 * - FFT
230 - Fast Fourier Transform
231 - `numpy.fft.fft2 <https://numpy.org/doc/stable/reference/generated/numpy.fft.fft2.html>`_
232 * - Inverse FFT
233 - Inverse Fast Fourier Transform
234 - `numpy.fft.ifft2 <https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft2.html>`_
235 * - Magnitude spectrum
236 - Optional: output in decibels (dB)
237 - | :math:`z_{1} = \left|\FFT\left(z_{0}\right)\right|` or
238 | :math:`z_{1} = 20 \log_{10} \left(\left|\FFT\left(z_{0}\right)\right|\right)` (dB)
239 * - Phase spectrum
240 - Phase of the FFT expressed in degrees, using `numpy.angle <https://docs.scipy.org/doc/numpy/reference/generated/numpy.angle.html>`_
241 - :math:`z_{1} = \angle\left(\FFT\left(z_{0}\right)\right)`
242 * - Power spectral density
243 - Optional: output in decibels (dB)
244 - | :math:`z_{1} = \left|\FFT\left(z_{0}\right)\right|^2` or
245 | :math:`z_{1} = 10 \log_{10} \left(\left|\FFT\left(z_{0}\right)\right|^2\right)` (dB)
246
247 .. note::
248
249 FFT and inverse FFT are performed using frequency shifting if the option is enabled
250 in DataLab settings (see :ref:`settings`).
251
252 Frequency-domain filters
253 ^^^^^^^^^^^^^^^^^^^^^^^^
254
255 The following frequency-domain filters are available:
256
257 .. list-table::
258 :header-rows: 1
259 :widths: 25, 75
260
261 * - Method
262 - Description
263 * - Butterworth
264 - Butterworth filter, based on `skimage.filters.butterworth <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.butterworth>`_
265 * - Gaussian filter
266 - Gaussian filter
267
268 Thresholding
269 ^^^^^^^^^^^^
270
271 Create a new image which is the result of thresholding on each selected image,
272 eventually based on user-defined parameters ("Parametric thresholding").
273
274 The following parameters are available when selecting "Parametric thresholding":
275
276 .. list-table::
277 :header-rows: 1
278 :widths: 25, 75
279
280 * - Parameter
281 - Description
282 * - Threshold method
283 - The thresholding method to use (see table below)
284 * - Bins
285 - Number of bins for histogram calculation
286 * - Value
287 - Threshold value
288 * - Operation
289 - Operation to apply (> or <)
290
291 The following thresholding methods are available:
292
293 .. list-table::
294 :header-rows: 1
295 :widths: 25, 75
296
297 * - Method
298 - Implementation
299 * - Manual
300 - Manual thresholding (user-defined parameters)
301 * - ISODATA
302 - `skimage.filters.threshold_isodata <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_isodata>`_
303 * - Li
304 - `skimage.filters.threshold_li <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_li>`_
305 * - Mean
306 - `skimage.filters.threshold_mean <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_mean>`_
307 * - Minimum
308 - `skimage.filters.threshold_minimum <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_minimum>`_
309 * - Otsu
310 - `skimage.filters.threshold_otsu <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_otsu>`_
311 * - Triangle
312 - `skimage.filters.threshold_triangle <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_triangle>`_
313 * - Yen
314 - `skimage.filters.threshold_yen <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.threshold_yen>`_
315
316 .. note::
317
318 The "All thresholding methods" option allows to perform all thresholding methods
319 on the same image. Combined with the "distribute on a grid" option, this allows
320 to compare the different thresholding methods on the same image.
321
322 Exposure
323 ^^^^^^^^
324
325 Create a new image which is the result of exposure correction on each selected image.
326
327 The following functions are available:
328
329 .. list-table::
330 :header-rows: 1
331 :widths: 25, 25, 50
332
333 * - Function
334 - Implementation
335 - Comments
336 * - Gamma correction
337 - `skimage.exposure.adjust_gamma <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.adjust_gamma>`_
338 -
339 * - Logarithmic correction
340 - `skimage.exposure.adjust_log <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.adjust_log>`_
341 -
342 * - Sigmoid correction
343 - `skimage.exposure.adjust_sigmoid <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.adjust_sigmoid>`_
344 -
345 * - Histogram equalization
346 - `skimage.exposure.equalize_hist <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.equalize_hist>`_
347 -
348 * - Adaptive histogram equalization
349 - `skimage.exposure.equalize_adapthist <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.equalize_adapthist>`_
350 - Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm
351 * - Intensity rescaling
352 - `skimage.exposure.rescale_intensity <https://scikit-image.org/docs/stable/api/skimage.exposure.html#skimage.exposure.rescale_intensity>`_
353 - Stretch or shrink image intensity levels
354
355 Restoration
356 ^^^^^^^^^^^
357
358 Create a new image which is the result of restoration on each selected image.
359
360 The following functions are available:
361
362 .. list-table::
363 :header-rows: 1
364 :widths: 25, 25, 50
365
366 * - Function
367 - Implementation
368 - Comments
369 * - Total variation denoising
370 - `skimage.restoration.denoise_tv_chambolle <https://scikit-image.org/docs/stable/api/skimage.restoration.html#denoise-tv-chambolle>`_
371 -
372 * - Bilateral filter denoising
373 - `skimage.restoration.denoise_bilateral <https://scikit-image.org/docs/stable/api/skimage.restoration.html#denoise-bilateral>`_
374 -
375 * - Wavelet denoising
376 - `skimage.restoration.denoise_wavelet <https://scikit-image.org/docs/stable/api/skimage.restoration.html#denoise-wavelet>`_
377 -
378 * - White Top-Hat denoising
379 - `skimage.morphology.white_tophat <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.white_tophat>`_
380 - Denoise image by subtracting its white top hat transform
381
382 .. note::
383
384 The "All denoising methods" option allows to perform all denoising methods
385 on the same image. Combined with the "distribute on a grid" option, this allows
386 to compare the different denoising methods on the same image.
387
388 Morphology
389 ^^^^^^^^^^
390
391 Create a new image which is the result of morphological operations on each selected image,
392 using a disk footprint.
393
394 The following functions are available:
395
396 .. list-table::
397 :header-rows: 1
398 :widths: 25, 75
399
400 * - Function
401 - Implementation
402 * - White Top-Hat (disk)
403 - `skimage.morphology.white_tophat <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.white_tophat>`_
404 * - Black Top-Hat (disk)
405 - `skimage.morphology.black_tophat <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.black_tophat>`_
406 * - Erosion (disk)
407 - `skimage.morphology.erosion <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.erosion>`_
408 * - Dilation (disk)
409 - `skimage.morphology.dilation <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.dilation>`_
410 * - Opening (disk)
411 - `skimage.morphology.opening <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.opening>`_
412 * - Closing (disk)
413 - `skimage.morphology.closing <https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.closing>`_
414
415 .. note::
416
417 The "All morphological operations" option allows to perform all morphological operations
418 on the same image. Combined with the "distribute on a grid" option, this allows to compare
419 the different morphological operations on the same image.
420
421 Edges
422 ^^^^^
423
424 Create a new image which is the result of edge filtering on each selected image.
425
426 The following functions are available:
427
428 .. list-table::
429 :header-rows: 1
430 :widths: 25, 75
431
432 * - Function
433 - Implementation
434 * - Canny filter
435 - `skimage.feature.canny <https://scikit-image.org/docs/stable/api/skimage.feature.html#skimage.feature.canny>`_
436 * - Farid filter
437 - `skimage.filters.farid <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters>`_
438 * - Farid filter (horizontal)
439 - `skimage.filters.farid_h <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.farid_h>`_
440 * - Farid filter (vertical)
441 - `skimage.filters.farid_v <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.farid_v>`_
442 * - Laplace filter
443 - `skimage.filters.laplace <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.laplace>`_
444 * - Prewitt filter
445 - `skimage.filters.prewitt <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.prewitt>`_
446 * - Prewitt filter (horizontal)
447 - `skimage.filters.prewitt_h <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.prewitt_h>`_
448 * - Prewitt filter (vertical)
449 - `skimage.filters.prewitt_v <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.prewitt_v>`_
450 * - Roberts filter
451 - `skimage.filters.roberts <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.roberts>`_
452 * - Scharr filter
453 - `skimage.filters.scharr <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.scharr>`_
454 * - Scharr filter (horizontal)
455 - `skimage.filters.scharr_h <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.scharr_h>`_
456 * - Scharr filter (vertical)
457 - `skimage.filters.scharr_v <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.scharr_v>`_
458 * - Sobel filter
459 - `skimage.filters.sobel <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.sobel>`_
460 * - Sobel filter (horizontal)
461 - `skimage.filters.sobel_h <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.sobel_h>`_
462 * - Sobel filter (vertical)
463 - `skimage.filters.sobel_v <https://scikit-image.org/docs/stable/api/skimage.filters.html#skimage.filters.sobel_v>`_
464
465 .. note::
466
467 The "All edges filters" option allows to perform all edge filtering algorithms
468 on the same image. Combined with the "distribute on a grid" option, this allows
469 to compare the different edge filters on the same image.
470
471 Erase area
472 ^^^^^^^^^^
473
474 Erase an area in the image as defined by a region of interest (ROI).
475
476 .. note::
477
478 The region to erase is defined by the user through a dialog box. It can consist of
479 a single ROI or multiple ROIs with various shapes (rectangular, circular, etc.).
480 Note that the ROI defined here is not bound to any object; it is used solely to
481 specify the area to erase in the image. In particular, it is independent of the
482 image’s ROI, if any (the latter is shown in the dialog box as a masked area).
483
484 Resize
485 ^^^^^^
486
487 Create a new image which is a resized version of each selected image.
488
489 Pixel binning
490 ^^^^^^^^^^^^^
491
492 Combine clusters of adjacent pixels, throughout the image,
493 into single pixels. The result can be the sum, average, median, minimum,
494 or maximum value of the cluster.
495
496 Resampling
497 ^^^^^^^^^^
498
499 Generate new images by resampling each selected image.
500 The following parameters are available:
501
502 .. list-table::
503 :header-rows: 1
504 :widths: 25, 75
505
506 * - Parameter
507 - Description
508 * - math:`x_{min}`
509 - Minimum x-coordinate of the output image
510 * - :math:`x_{max}`
511 - Maximum x-coordinate of the output image
512 * - :math:`y_{min}`
513 - Minimum y-coordinate of the output image
514 * - :math:`y_{max}`
515 - Maximum y-coordinate of the output image
516 * - Mode
517 - Image size definition mode: 'Pixel size' or 'Output shape'. The 'Pixel size' mode
518 allows to define the pixel size of the new image, while the 'Output shape' mode
519 allows to define the number of pixels of the new image.
520 * - ΔX
521 - Pixel size in x-direction (if 'Pixel size' mode is selected)
522 * - ΔY
523 - Pixel size in y-direction (if 'Pixel size' mode is selected)
524 * - Width
525 - Output image width in pixels (if 'Output shape' mode is selected)
526 * - Height
527 - Output image height in pixels (if 'Output shape' mode is selected)
528 * - Interpolation method
529 - Interpolation method to use: 'nearest', 'linear', 'cubic'
530 * - Fill value
531 - Value to use for points outside the input image domain (if None, function uses NaN for extrapolation)