Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image segmentation to identify migration area #5

Open
vektorious opened this issue Apr 5, 2018 · 4 comments
Open

Image segmentation to identify migration area #5

vektorious opened this issue Apr 5, 2018 · 4 comments
Labels
help wanted Extra attention is needed mozsprint openCV Open source computer Vision python Preferred code language

Comments

@vektorious
Copy link
Owner

vektorious commented Apr 5, 2018

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

@vektorious vektorious added mozsprint help wanted Extra attention is needed labels Apr 5, 2018
@vektorious vektorious added learn python Minimal knowledge of python required: great for learning something new! openCV Open source computer Vision python Preferred code language and removed learn python Minimal knowledge of python required: great for learning something new! labels Apr 23, 2018
@jmoldon
Copy link
Collaborator

jmoldon commented May 10, 2018

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 Detection of agar plate location in image #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.

@vektorious
Copy link
Owner Author

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!

@jmoldon
Copy link
Collaborator

jmoldon commented May 10, 2018

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.

@vektorious
Copy link
Owner Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed mozsprint openCV Open source computer Vision python Preferred code language
Projects
None yet
Development

No branches or pull requests

2 participants