If you like our website, you may want to buy us a coffee : )
by Enzo De Bernardini
This article will discuss the way to apply one or more processes on a set of image automatically, which is called batch processing. This type of technique is useful in cases where you need to run the same process on a large number of images. The general idea is to have two main sets: The ImageContainer which will have the images, and the ProcessContainer which will have the processes to apply over the images.
The ImageContainer allow to group the files that will be processed. To access it: right click on a free place of the workspace and select the option Image Container from the contextual menu, or utilize the shortcut CTRL+ALT+I.
The main windows of ImageContainer lets you add the files to be processed and set the different parameters, being the most important the target path for new files to be created and the new name of the files, including the extension.
Configuration sept by step:
Click on the button Add Files to add the files you want to be processed.
Select the Output directory for the images already processed by clicking on the icon to the right of the corresponding field.
In the Output template field, set the format of the name and extension type. As far as the name, you can keep the name of the source files using the expression &filename;, or change it to convenience. To keep the same extension as the source files, use the expression &extension;. But if we want to save the files in another format, for example .fit, add .fit at the end of the field. A full list of available expressions can be seen by clicking on the button ? located to the right of the field. In our example we will use the following notation: &count;_&filename;.fit, which simply will add a prefix numbering files (&count;), followed by a separator character (_), then keep the original name (&filename;) and store the generated files in FITS (.fit) format.
Optionally you can press the Run Diagnostics button to verify that all settings are correct.
Generate an instance icon dragging and dropping the blue triangle located in the lower left corner of the windows of ImageContainer to an open area of the workspace (see video about how to generate an instance icon).
If you want to omit one or several images from the list (for example for testing the procedure before running the whole lot) can disable an image by double clicking on the green icon (check mark), which will become a red x, indicating that the image was deactivated and will not be processed.
The following video illustrates the simplified procedure:
Then you must prepare the set of processes that will be applied to all the images grouped in the ImageContainer instance previosly created. For this example we will assume that we want to resize and make an adjustment of histogram to the set of images.
As first step you can open one of the image involved, any of them, and apply each process that will then be executed over the set of images. This is just an example, so you must adapt the concept exposed to the particular needs of the processing. Most of the processes support this type of batch processing.
Processing step by step:
Open one of the images involved CTRL + O, or double click on a free area on the workspace to open the corresponding file explorer.
Following the example, resize the image using the process Resample (Process › Geometry › Resample)
And finally, for this simple example, an histogram adjustment using HistogramTransformation tool:
Once all the necessary processes were applied on the image, you must open the History Explorer window and select the image from the dropdown menu below, to view the history of the image (if this window is not visible, enable it from the menu View › Explore Windows › History Explorer).
From History Explorer should now generate an instance icon that contains all processes, a ProcessContainer. To do this, drag and drop the blue triangle in the lower left corner to a free area of the workspace. Thus, on that icon, will be encapsulated all processes applied to the image (in this case two: Resample and HistogramTransformation). The following video shows the procedure:
Having generated the ImageContainer instance icon and the ProcessContainer instance icon everything is ready for batch processing. Simply drag and drop the ProcessContainer icon over the ImageContainer icon.
If all went well, the processes encapsulated within ProcessContainer will be applied to all images grouped within ImageContainer, creating new files in the specified destination path and with the configured features. We can check it by opening the route and checking the files.
If you want to skip the application of any of the processes encapsulated in ProcessContainer, you can open it by double clicking on its icon to disable the corresponding process by double clicking on the green icon (check mark), which will become a red x, indicating that the process was deactivated and will not be applied. Once done, you must generate a new instance icon of ProcessContainer dragging the blue triangle on a free area of the workspace, or update the existing icon by dragging the blue triangle on it.
Most of the processes can be encapsulated into a ProcessContainer and be applied to an ImageContainer as descibed. This feature is extremely useful when applied repetitive processes to a large number of image, greatly simplifying the task.