Public Lab Research note


Python and openCV to analyze microscope slide images of airborne particles

by amirberAgain |

Following the Jan 9th air quality open call I wanted to see what can be done with a microscope slide image of airborne particles. Inspired by the work started by Mathew and Stevie a couple of years ago I set out to try and get a similar process running on Python using openCV and skimage. Based on an old tutorial to detect coins I repurposed it for a single slide example. Once more example images are obtained this process could be made more robust, could also be a great candidate for DL!


Below is a code walkthrough:

1. load image, crop out the area with the scale on it.image description

2. Use Sobel edge detection to find particles.image description

3. Use a simple threshold to binarize the edges image.image description

4. Label binarized features.image description

5. Show area distribution of the particlesimage description

6. Sort and select only features which are larger than sizeTh (4 pX).

  • NOTE: I made a lazy assumption that each pixel is 1 um, this parameter can be adapted in the code to show real scale, this is a pixel scale - NOT um!

Largest:image description

Smallest:image description

6. TBC (use fractal dimension to detect if a particle is round or jagged). find a way to avoid false detection of two close particles, and from false detection of a section of large particles being reidentified by the label function.image description



air-quality microscope passive-particle-monitors microscopy particle-imaging


7 Comments

Hi, some days ago I talked about this topic with a friend of mine... the usecase is ongoing pollen analysis. Do you know whether there are pollen micro images which can be used to classify a particle as a pollen... and even better, also to classify from which tree/plant it comes?

Is this a question? Click here to post it to the Questions page.


This sounds very interesting, but I don't have any raw data. Maybe join the Tue. open call? I think this can be a great study case for ML/DL. Googling a bit got me to this 1939 post form pop-sci: https://books.google.co.il/books?id=7SwDAAAAMBAJ&pg=PA188&as_brr=1&cd=2&redir_esc=y#v=onepage&q&f=false

Is this a question? Click here to post it to the Questions page.


Hi, I'm trying to think how we can support and connect this work to the microscope team more -- could we post a call for images to try to run through this workflow? Both reference images and test images from DIY microscopes?

Maybe as a follow-on to this question: https://publiclab.org/questions/gretchengehrke/09-21-2017/is-it-possible-to-discern-jagged-from-rounded-particles-using-a-diy-microscope

Is this a question? Click here to post it to the Questions page.


In the comment section of the post linked below there is a link to a large cohort of images, thou I'm not sure if they represent airborne dust particles. Having looked at the posts from the last couple of years by many Public lab collaborators I feel that this issue has been dealt with rather well, so I'm not sure if the small code snippet I wrote is that relevant. That being said - I will be happy to upload it somewhere, is there a section of the git where it should go?

https://publiclab.org/notes/SimonPyle/05-13-2016/automating-imagej-for-particle-image-analysis

Is this a question? Click here to post it to the Questions page.


Oh yes please -- maybe make a new repository for now? Or use http://gist.github.com if it's just a few files.

Could you link to it from here? I think having a second implementation -- and a more standalone one -- could be quite valuable.

Is this a question? Click here to post it to the Questions page.


For now, my code and iamge excerpt can be found here, just untill I figure out how to have two git users on my machine, https://drive.google.com/drive/folders/1X0IK45IXxDBqPuxKQUqOQp-5BeLDu9zw?usp=sharing

Is this a question? Click here to post it to the Questions page.


@amirberAgain - a friend just posted this question, and I'm curious if you think any of the steps you wrote out are applicable to that kind of analysis as well -- https://publiclab.org/questions/jlev/02-01-2018/how-can-i-identify-bits-of-plastic-from-the-beach-in-an-image

@dakoller it'd be great to hear more about your interest in pollen too -- would you like to post it as a related question using the link under your comment?

In general, I'm trying to think through how these steps could be laid out one by one, for potentially solving in a modular way, like using ImageSequencer, in parallel to what @amirberAgain has done in Python -- with an eye to reusability across different similar challenges -- pollen, microplastics, dust. What do you think?

Is this a question? Click here to post it to the Questions page.


You must be logged in to comment.