vektorious/mbac

Image segmentation to identify migration area

Opened this issue · 4 comments

The next step after localizing the agar plate is the identification of bacteria on the agar plate. They will appear as a white area which starts to spread over time.

To calculate the migration speed the edges of the area have to be determined on each image to segment it and calculate the migration area over time.

We can use the test pictures when we are writing a script

Hi from the global sprint in Manchester!

This is just a short introduction to let you know that I have been working on this. Still work in progress and I want to clean up code before proceeding, so just a summary of what I got so far.

I'm using python to process the images of individual plates. I'm using skimage to generate clusters on the central part of each image, make them uniform and select according to a threshold the clusters that seem to have activity.

This is an example of what I'm obtaining. Subplots from left to right:

  • raw image
  • raw image cutting the external part. This should be more accurate using #4, but for now I'm cutting from a certain radius of the image, which works well enough for now.
  • Clusters colored by average pixes intensity. I classify using skimage.segmentation.slic. More details and examples in this tutorial.
  • I select only the clusters that are above a certain threshold (currently set by hand).
  • Same as previous one but showing the delimited area.

image0211

With using average pixel values within each cluster I get good results. These are the plots for a few images randomly selected.

animated

Finally, to compute the area covered I just count pixels within the selected clusters. This is related to #6. This is an example for the images above, just plotting number of pixels vs iteration (the image sequence is not linear!):

areas

Sorry I don't have more time today to upload clean code. Tomorrow more. Any suggestions welcomed, both from the technical part or from what you actually need, as I'm not familiar with the details of the project.

Oh wow @jmoldon! This looks awesome!

Did you already play around with the threshold already? Because in image 225 there is a hole forming inside the area and after image 255 basically everything is filled on the top left. If this could be avoided the readout would be accurate enough.

I already tried a completely different approach some time ago calculation just the differences between the images in a certain area. But this produces so much noise..
Have a look at the video

Apart from that I think it should be very different with future image produced by the dark field lighting setup because it will generate a better contrast (bacteria/agar)! So I guess this could work very well!

I think @2alin is trying a different approach using openCV for #4 and we have to see how good this will work! Let's talk tomorrow when you have more time! If you like you can you our MozSprint Gitter Channel because we are discussing everything right there!

OK great.

There are different thresholds to play with: the threshold to generate the clusters, which we can also modify with some gaussian filtering, and the threshold to select which clusters to classify as relevant. Currently I fixed the values checking one or two images and applied blindly to the rest. So we can surely find more suitable and robust parameters depending on the illumination/contrast.

Good that you are already improving the illumination, first I tried other methods but the contrast was not enough. With better bacteria/agar separation we will avoid those glitches much better.

I'm using skimage because the segmentation tools look pretty nice, but probably there is something similar in open-cv. It will be good to use only one to keep dependencies low.

Thanks for sharing the gitter channel, I will follow you there.

Good that you are already improving the illumination, first I tried other methods but the contrast was not enough. With better bacteria/agar separation we will avoid those glitches much better.

On the other hand there are bacterial species which are very translucent and it would be nice to be able to use the script with a challenging contrast.

Anyways, we will see what proves better and then decide for either openCV or skimage if this is fine with you!