SEM automation guidelines for small script development: image analysis

By Wouter Arts - Jul 12, 2018

Scripts are small automated software tools that can help a scanning electron microscope (SEM) user with their work. In my previous blog I wrote about how SEM images can be acquired with the Phenom Programming Interface (PPI) using a small script. In this blog I will explain how to extract physical properties from those SEM images.

Workflows for SEM automation

Typically, SEM workflows always consist of the same steps, see Figure 1. The four steps that can be automated using the PPI are:

  1. Image acquisition
  2. Analysis
  3. Evaluation
  4. Reporting

In the image acquisition step (1), images are automatically made using PPI and the Phenom SEM. In the analysis step (2), the physical properties are extracted from the image. The images are evaluated based on these physical properties in the evaluation step (3). The final automated step (4) is reporting the results back to the user.

 phenom blog ppi guidelines-1

Figure 1: Scanning Electron Microscopy workflow

SEM image analysis 

This blog will focus on step 2: the analysis step. The analysis is the image processing that takes place to obtain physical quantities from an SEM image. This could be for example:

  • Thresholding BSD images to quantify compositional differences in the image
  • Segmenting the image to find particles
  • Measuring the working distance to detect a height step in your sample

We will continue with the script from the previous blog. In that blog, an automation script was written to acquire images from a copper-aluminum stub. I also explained how the information obtained with the BSD detector gives compositional contrast.

In this blog we will use those images and information to segment them into a copper and aluminum part. The script to obtain the images can be found in code snippet 1.

Schermafbeelding 2018-07-05 om 11.55.33

Code snippet 1: PPI script to acquire an image of the copper and aluminum part of the stub

Now I will explain how the images can be segmented based on contrast by doing the following steps:

  • Acquire image with only aluminum
  • Acquire image with only copper
  • Determine (automatically) the gray levels associated with the metals
  • Acquire a new image that contains an area with both copper and aluminum
  • Segment the new image into a copper and aluminum part

Firstly, two images are acquired containing only one of the elements. From these images the associated gray level can be determined. To show how this works the histograms of the two images are plotted in one graph, see Figure 2. The aluminum peak can be seen around 32000 and the copper peak is around 36000. The gaussian spread of the peaks is overlapping, at around 34000. The thresholding values should be unambiguous, therefore the threshold values should not overlap.

Schermafbeelding 2018-07-05 om 11.56.35

Figure 2: Histograms of the images

Determining the appropriate values can be done automatically using NumPy. We first determine the mean, which should be close to the peaks. The spread we can get from the standard deviation. This can be done by adding the code in snippet 2 to the script from the previous blog (In code snippet 4 you can find the complete code, including the code from the previous blog).

Schermafbeelding 2018-07-05 om 12.08.41

Code snippet 2: Script to obtain average and standard deviation of the images

The output of this part of the script is:

Schermafbeelding 2018-07-05 om 11.59.13

These values are very close to the values we got just by looking at the histogram. A reasonable threshold is the mean plus or minus twice the standard deviation.

Segmentation

The information about the gray values that was obtained in the previous part can be used to segment a new image. This new image has both an area with copper and an area with aluminum. To segment the images, OpenCV will be used. The threshold value will be: μ±2σ.

To do this we must first import OpenCV into Python as cv2. We obtain the new image (with a longer exposure time to reduce noise) at a new location. Then we blur the image to reduce the noise levels further (thereby making the peaks sharper) and segment based on the contrast levels. In the final step we calculate the relative areas of the metal parts. The code to do this is as follows:

 Schermafbeelding 2018-07-05 om 12.09.24

Code snippet 3: Code to segment the image

The  code in snippet 3 first moves the stage to a position where both the copper and aluminum part is visible. The image is acquired using the phenom.SemAcquireImage method. In Figure 3, the acquired image is shown on the left-hand side. Using OpenCV the image is image is blurred using a circular Gaussian kernel with a diameter of 9 pixels. This reduces the noise in the image to improve the segmentation.

This blurred image is segmented using the cv2.inRange method. This method yields a binary image with the white being the segmented part of the image. The two images on the right-hand side of Figure 3 are the segmented results. From the resulting images, the relative percentage of copper and aluminum can be calculated using the print function. The extra division by 255 after the sum is because they are 8-bit images and the white values are therefore 255. The area of copper in this image is 44% and aluminum is 37%, the remaining 19% is other material.

 Schermafbeelding 2018-07-05 om 12.10.49

Figure 3: Image to segment, and the segmented parts

The segmentation results conclude this blog post. The complete code including all the extra plotting is shown in code snippet 4. In the next blog I will explain how the physical properties that we have obtained in this blog can be used to evaluate your sample.

Schermafbeelding 2018-07-05 om 12.11.16

 Code snippet 4: Complete code including all plotting

I know computing the standard deviation in NumPy can yield some skewed results because a Poisson distribution is assumed. For the sake of simplicity I assume this method to be close enough, and actually, for samples that are not heavily contaminated, the results will be completely acceptable.

Automate your own SEM image acquisition and analysis routine

Want to learn more about PPI? And would you like to save a substantial amount of time in your image acquisition routine? Download our PPI spec sheet and find out how PPI can help you work more efficiently. In my next blog I’ll explain how you can use base actions on the physical properties that have been retrieved in this blog.

Download your Phenom Programming Interface sheet


About the author

Wouter Arts is Application Software Engineer at Thermo Fisher Scientific, the world leader in serving science. He is interested in finding new smart methods to convert images to physical properties using the Phenom desktop SEM. In addition, he develops scripts to help companies in using the Phenom desktop SEM for automated processes.

Press Room | Privacy Policy | Terms of Use | Sitemap