Size of SARS-Cov2 virions in class

© 2021 Tom Röschinger. This work is licensed under a Creative Commons Attribution License CC-BY 4.0. All code contained herein is licensed under an MIT license

This notebook is heavily inspired by this lesson by Justin Bois.


First we need to import the image and load it using skimage.

We are going to plot a lot of images in this notebook, so let's write a short function that returns an image given a 2D array.

For now, let's ignore the scalebar, so we remove that part of the image.

The first step is to remove the background. For that purpose, we use a gaussian filter. That means, that each pixel is replaced by an weighted area of its surrounding pixels, where the weights are given by a 2D gaussian distribution. Before we can do that, we have to transform the array of integers into an array of floats.

Now we can subtract the background from our image and then renormalize the image.

After background subtraction, we can start identifying particles. To get a better feeling at our progress, we will zoom in a little.

There is plenty of "noise" in the background, which might make the next step a little tricky. Therefore, let's apply a gaussian filter with small radius.

By eye, we can cleary identify where the virions are. However, we need to be able to tell the computer as well. Therefore, we are performing a step called thresholding. Before we can do that, let's look at a histogram of pixel values.

The large peak at lower intensity values is the background. So if we choose a threshold about 0.55, we should be able to get rid of as much background as possible.

This is already a good starting point. Two main things remain to do here. First, we should get rid of the small background points that are remaining, and second, we should fill the holes that still remain inside the particles.

We got some good looking virions in here. There is still a lot of "garbage" in the image, some of which we can remove by clearing the border. This also remomves particles that are cut off at the borders, and would only give a partial area.

We did a good job in identifying particels. We have some issues with separating particles that are close together. This can be solved by using other methods of segmentation, which we will not discuss here. Before we can compute the actual particle size, we need to find the size if a pixel.

Looks like there are 75 pixels between two bars. The space between two bars relates to 500nm, so now we know how large each pixel is. Now we can compute the size of each object. Also, we compute the eccentricity and use that as a filtering criteria.

Let's plot a histogram of results!