Measuring Fabry-Perot fringes#

This example shows how to measure Fabry-Perot fringes using the image processing features of DataLab:

  • Load an image of a Fabry-Perot interferometer

  • Define a circular region of interest (ROI) around the central fringe

  • Detect contours in the ROI and fit them to circles

  • Show the radius of the circles

  • Annotate the image

  • Copy/paste the ROI to another image

  • Extract the intensity profile along the X axis

  • Save the workspace

First, we open DataLab and load the images:

../../_images/012.png

Open the image files with “File > Open…”, or with the fileopen_ima button in the toolbar, or by dragging and dropping the files into DataLab (on the panel on the right).#

../../_images/022.png

Select the test images “fabry_perot1.jpg” and “fabry_perot2.jpg” and click “Open”.#

The selected image is displayed in the main window. We can zoom in and out by pressing the right mouse button and dragging the mouse up and down. We can also pan the image by pressing the middle mouse button and dragging the mouse.

../../_images/032.png

Zoom in and out with the right mouse button. Pan the image with the middle mouse button.#

Note

When working on application-specific images (e.g. X-ray radiography images, or optical microscopy images), it is often useful to change the colormap to a grayscale colormap. If you see a different image colormap than the one shown in the figure, you can change it by selecting the image in the visualization panel, and the selecting the colormap in the vertical toolbar on the left of the visualization panel.

Or, even better, you can change the default colormap in the DataLab settings by selecting “Edit > Settings…” in the menu, or the libre-gui-settings button in the toolbar.

../../_images/default_colormap.png

Select the “Visualization” tab, and select the “gray” colormap.#

Then, let’s define a circular region of interest (ROI) around the central fringe.

../../_images/042.png

Select the “Edit regions of interest” tool in the “Analysis” menu.#

../../_images/052.png

The “Regions of interest” dialog opens. Click “Add ROI” and select a circular ROI. Resize the predefined ROI by dragging the handles. Note that you may change the ROI radius while keeping its center fixed by pressing the “Ctrl” key. Click “OK” to close the dialog.#

../../_images/062.png

Another dialog box opens, and asks you to confirm the ROI parameters. Click “OK”.#

../../_images/072.png

The ROI is displayed on the image: masked pixels are grayed out, and the ROI boundary is displayed in blue (note that, internally, the ROI is defined by a binary mask, i.e. image data is represented as a NumPy masked array).#

Now, let’s detect the contours in the ROI and fit them to circles.

../../_images/082.png

Select the “Contour detection” tool in the “Analysis” menu.#

../../_images/092.png

The “Contour” parameters dialog opens. Select the shape “Circle” and click “OK”.#

../../_images/102.png

The “Results” dialog opens, and displays the fitted circle parameters. Click “OK”.#

../../_images/112.png

The fitted circles are displayed on the image.#

Note

If you want to show the analysis results again, you can select the “Show results” show_results entry in the “Analysis” menu, or the “Show results” show_results button, below the image list:

../../_images/121.png

The images (or signals) can also be displayed in a separate window, by clicking on the “View in a new window” entry in the “View” menu (or the new_window button in the toolbar). This is useful to compare side by side images or signals.

../../_images/131.png

The image is displayed in a separate window. The ROI and the fitted circles are also displayed. Annotations can be added to the image by clicking on the buttons at the bottom of the window. The annotations are stored in the metadata of the image, and together with the image data when the workspace is saved. Click on “OK” to close the window.#

../../_images/14.png

The image is displayed in the main window, together with the annotations.#

If you want to take a closer look at the metadata, you can open the “Metadata” dialog.

../../_images/15.png

The “Metadata” button is located below the image list.#

../../_images/16.png

The “Metadata” dialog opens. Among other information, it displays the annotations (in a JSON format), some style information (e.g. the colormap), and the ROI.#

Now, let’s delete the image metadata (including the annotations) to clean up the image.

../../_images/17.png

Select the “Delete metadata” entry in the “Edit” menu, or the metadata_delete button in the toolbar.#

../../_images/18.png

The “Delete metadata” dialog opens. Click “No” to keep the ROI and delete the rest of the metadata.#

If we want to define the exact same ROI on the second image, we can copy/paste the ROI from the first image to the second image, using the metadata.

../../_images/19.png

Select the “Copy metadata” entry in the “Edit” menu, or the metadata_copy button in the toolbar.#

../../_images/20.png

Select the second image in the “Images” panel, then select the “Paste metadata” entry in the “Edit” menu, or the metadata_paste button in the toolbar.#

../../_images/21.png

The ROI is added to the second image.#

../../_images/22.png

Select the “Contour detection” tool in the “Analysis” menu, with the same parameters as before (shape “Circle”). On this image, there are two fringes, so four circles are fitted. The “Results” dialog opens, and displays the fitted circle parameters. Click “OK”.#

../../_images/23.png

The fitted circles are displayed on the image.#

To extract the intensity profile along the X axis, we have two options:

  • Either select the “Line profile…” entry profile in the “Operations > Intensity profiles” menu.

  • Or activate the “Cross section” tool cross_section in the vertical toolbar on the left of the visualization panel.

Let’s try the first option, by selecting the “Line profile…” entry profile: that is the most straightforward way to extract a profile from an image, and it corresponds to the compute_profile method of DataLab’s API (so it can be used in a script, a plugin or a macro).

../../_images/24.png

Select the “Line profile…” entry profile in the “Operations” menu.#

../../_images/25.png

The “Profile” dialog opens. Enter the row of the horizontal profile (or the column of the vertical profile) in the dialog box that opens. Click “OK”.#

../../_images/26.png

The intensity profile is added to the “Signals” panel, and DataLab switches to this panel to display the profile.#

If you want to do some measurements on the profile, or add annotations, you can open the signal in a separate window, by clicking on the “View in a new window” entry in the “View” menu (or the new_window button in the toolbar).

../../_images/27.png

The signal is displayed in a separate window. Here, we added vertical cursors and a very interesting text label. As for the images, the annotations are stored in the metadata of the signal, and together with the signal data when the workspace is saved. Click on “OK” to close the window.#

Now, let’s try the second option for extracting the intensity profile along the X axis, by activating the “Cross section” tool cross_section in the vertical toolbar on the left of the visualization panel (this tool is a PlotPy feature). Before being able to use it, we need to select the image in the visualization panel (otherwise the tool is grayed out). Then, we can click on the image to display the intensity profile along the X axis. DataLab integrates a modified version of this tool, that allows to transfer the profile to the “Signals” panel for further processing.

../../_images/28.png

Switch back to the “Images” panel, and select the image in the visualization panel (otherwise the “Cross section” cross_section tool is grayed out). Select the “Cross section” tool cross_section in the vertical toolbar, and click on the image to display the intensity profiles along the X and Y axes.#

Then, click on the “Process signal” button to_signal in the toolbar near the profile to transfer the profile to the “Signals” panel.

../../_images/29.png

The intensity profile is added to the “Signals” panel, and DataLab switches to this panel to display the profile.#

Finally, we can save the workspace to a file. The workspace contains all the images and signals that were loaded or processed in DataLab. It also contains the analysis results, the visualization settings (colormaps, contrast, etc.), the metadata, and the annotations.

../../_images/30.png

Save the workspace to a file with “File > Save to HDF5 file…”, or the filesave_h5 button in the toolbar.#

If you want to load the workspace again, you can use the “File > Open HDF5 file…” (or the fileopen_h5 button in the toolbar) to load the whole workspace, or the “File > Browse HDF5 file…” (or the h5browser button in the toolbar) to load only a selection of data sets from the workspace.