| 1 |
.. _ima-menu-file: |
| 2 |
|
| 3 |
Open and save Images |
| 4 |
==================== |
| 5 |
|
| 6 |
This section describes how to open and save images (and workspaces). |
| 7 |
|
| 8 |
.. note:: |
| 9 |
|
| 10 |
For creating new images from mathematical models, see :ref:`ima-menu-create`. |
| 11 |
|
| 12 |
.. figure:: /images/shots/i_file.png |
| 13 |
|
| 14 |
Screenshot of the "File" menu. |
| 15 |
|
| 16 |
When the "Image Panel" is selected, the menus and toolbars are updated to |
| 17 |
provide image-related actions. |
| 18 |
|
| 19 |
The "File" menu allows you to: |
| 20 |
|
| 21 |
- Open, save and close images (see below). |
| 22 |
|
| 23 |
- Save and restore the current workspace or browse HDF5 files (see :ref:`overview`). |
| 24 |
|
| 25 |
- Edit DataLab preferences (see :ref:`settings`). |
| 26 |
|
| 27 |
.. _open_image: |
| 28 |
|
| 29 |
Open image |
| 30 |
^^^^^^^^^^ |
| 31 |
|
| 32 |
Create a new image from the following supported filetypes: |
| 33 |
|
| 34 |
.. list-table:: |
| 35 |
:header-rows: 1 |
| 36 |
|
| 37 |
* - File type |
| 38 |
- Extensions |
| 39 |
* - PNG files |
| 40 |
- .png |
| 41 |
* - TIFF files |
| 42 |
- .tif, .tiff |
| 43 |
* - 8-bit images |
| 44 |
- .jpg, .gif |
| 45 |
* - NumPy arrays |
| 46 |
- .npy |
| 47 |
* - MAT-Files |
| 48 |
- .mat |
| 49 |
* - Text files |
| 50 |
- .txt, .csv, .asc |
| 51 |
* - Andor SIF files |
| 52 |
- .sif |
| 53 |
* - Princeton Instruments SPE files |
| 54 |
- .spe |
| 55 |
* - Opticks GEL files |
| 56 |
- .gel |
| 57 |
* - Hammamatsu NDPI files |
| 58 |
- .ndpi |
| 59 |
* - PCO Camera REC files |
| 60 |
- .rec |
| 61 |
* - SPIRICON files |
| 62 |
- .scor-data |
| 63 |
* - FXD files |
| 64 |
- .fxd |
| 65 |
* - Bitmap images |
| 66 |
- .bmp |
| 67 |
* - FT-Lab files |
| 68 |
- .ima |
| 69 |
|
| 70 |
.. note:: |
| 71 |
|
| 72 |
DataLab also supports any image format that can be read by the `imageio` library, |
| 73 |
provided that the associated plugin(s) are installed (see `imageio documentation <https://imageio.readthedocs.io/en/stable/formats/index.html>`_) |
| 74 |
and that the output NumPy array data type and shape are supported by DataLab. |
| 75 |
|
| 76 |
To add a new file format, you may use the `imageio_formats` entry of DataLab configuration file. |
| 77 |
This entry is a formatted like the `IMAGEIO_FORMATS` object which represents the natively supported formats: |
| 78 |
|
| 79 |
.. autodata:: sigima.config.IMAGEIO_FORMATS |
| 80 |
|
| 81 |
Open from directory |
| 82 |
^^^^^^^^^^^^^^^^^^^ |
| 83 |
|
| 84 |
Open multiple images from a specified directory. |
| 85 |
|
| 86 |
Save image |
| 87 |
^^^^^^^^^^ |
| 88 |
|
| 89 |
Save current image (see "Open image" supported filetypes). |
| 90 |
|
| 91 |
Save images to directory |
| 92 |
^^^^^^^^^^^^^^^^^^^^^^^^ |
| 93 |
|
| 94 |
Save all selected images to a specified directory, with configurable filename pattern |
| 95 |
and image format. |
| 96 |
|
| 97 |
.. figure:: /images/shots/i_save_to_directory.png |
| 98 |
|
| 99 |
Save images to directory dialog. |
| 100 |
|
| 101 |
When you select "Save to directory..." from the File menu, a dialog appears where you can: |
| 102 |
|
| 103 |
- **Directory**: Choose the target directory where images will be saved |
| 104 |
- **Filename pattern**: Define a pattern for the filenames using Python format strings |
| 105 |
- **File extension**: Select the output format (.png, .tiff, .h5ima, etc.) |
| 106 |
- **Overwrite**: Choose whether to overwrite existing files |
| 107 |
- **Preview**: See the list of files that will be created (with object IDs) |
| 108 |
|
| 109 |
The filename pattern supports the following placeholders: |
| 110 |
|
| 111 |
- ``{title}``: Image title |
| 112 |
- ``{index}``: 1-based index of the image in the selection (with zero-padding) |
| 113 |
- ``{count}``: Total number of selected images |
| 114 |
- ``{xlabel}``, ``{xunit}``, ``{ylabel}``, ``{yunit}``, ``{zlabel}``, ``{zunit}``: Axis labels and units |
| 115 |
- ``{metadata[key]}``: Access metadata values |
| 116 |
|
| 117 |
You can also use format modifiers, for example ``{index:03d}`` will format the index |
| 118 |
with 3 digits zero-padding (001, 002, 003, etc.). |
| 119 |
|
| 120 |
Import text file |
| 121 |
^^^^^^^^^^^^^^^^ |
| 122 |
|
| 123 |
DataLab can natively import many types of image files (e.g. TIFF, JPEG, PNG, etc.). |
| 124 |
However some specific text file formats may not be supported. In this case, you can |
| 125 |
use the `Import text file` feature, which allows you to import a text file and |
| 126 |
convert it to an image. |
| 127 |
|
| 128 |
This feature is accessible from the `File` menu, under the `Import text file` option. |
| 129 |
|
| 130 |
It opens an import wizard that guides you through the process of importing the text |
| 131 |
file. |
| 132 |
|
| 133 |
Step 1: Select the source |
| 134 |
------------------------- |
| 135 |
|
| 136 |
The first step is to select the source of the text file. You can either select a file |
| 137 |
from your computer or the clipboard if you have copied the text from another |
| 138 |
application. |
| 139 |
|
| 140 |
.. figure:: ../../images/import_text_file/i_01.png |
| 141 |
:alt: Step 1: Select the source |
| 142 |
:align: center |
| 143 |
|
| 144 |
Step 1: Select the source |
| 145 |
|
| 146 |
Step 2: Preview and configure the import |
| 147 |
----------------------------------------- |
| 148 |
|
| 149 |
The second step consists of configuring the import and previewing the result. You can |
| 150 |
configure the following options: |
| 151 |
|
| 152 |
- **Delimiter**: The character used to separate the values in the text file. |
| 153 |
- **Comments**: The character used to indicate that the line is a comment and should be |
| 154 |
ignored. |
| 155 |
- **Rows to Skip**: The number of rows to skip at the beginning of the file. |
| 156 |
- **Maximum Number of Rows**: The maximum number of rows to import. If the file contains |
| 157 |
more rows, they will be ignored. |
| 158 |
- **Transpose**: If checked, the rows and columns will be transposed. |
| 159 |
- **Data type**: The destination data type of the imported data. |
| 160 |
|
| 161 |
When you are done configuring the import, click the `Apply` button to see the result. |
| 162 |
|
| 163 |
.. figure:: ../../images/import_text_file/i_02.png |
| 164 |
:alt: Step 2: Configure the import |
| 165 |
:align: center |
| 166 |
|
| 167 |
Step 2: Configure the import |
| 168 |
|
| 169 |
.. figure:: ../../images/import_text_file/i_03.png |
| 170 |
:alt: Step 2: Preview the result |
| 171 |
:align: center |
| 172 |
|
| 173 |
Step 2: Preview the result |
| 174 |
|
| 175 |
Step 3: Show graphical representation |
| 176 |
------------------------------------- |
| 177 |
|
| 178 |
The third step shows a graphical representation of the imported data. You can use the |
| 179 |
`Finish` button to import the data into DataLab workspace. |
| 180 |
|
| 181 |
.. figure:: ../../images/import_text_file/i_04.png |
| 182 |
:alt: Step 3: Show graphical representation |
| 183 |
:align: center |
| 184 |
|
| 185 |
Step 3: Show graphical representation |