mWater / mWater-Android-App

An Android App that snaps a picture of a petrifilm, counts the bacteria and posts the counts on a server for the mWater project
https://github.com/AndroidImageProcessing
GNU General Public License v3.0
24 stars 16 forks source link

Find a non-hacky way for thresholding and filtering out background #33

Closed pakdel closed 12 years ago

pakdel commented 12 years ago

For the moment, adaptiveThreshold is quite hacky.

grassick commented 12 years ago

We now use a high-pass filter that correctly respects the edge of the mask. The high-pass filter uses a low-pass filter that is a simple box filter.

We need a better background detection algorithm that allows gradients and other low-freq background changes, but is not changed by lots of dark colonies.

grassick commented 12 years ago

@pakdel Thanks again for the c++ code that you wrote to do the filtering! It was it that I adapted to the new algorithm in jni_part.cpp.

We'll need to make a standalone version again of the c++ code for testing algorithm changes without an upload to the android client. Also, the gaussian fitting might be a better choice for background filter, though I'm not sure that using the peak histogram value as mean is robust enough.

grassick commented 12 years ago

@pakdel I wrote a new algorithm to remove yellow lines by replacing green (G) and blue (B) with:

G * (1+lambda) - B * (lambda)

where lambda is calculated to minimize edges. Works great! Yellow lines go away completely!

pakdel commented 12 years ago

That's great. I will restart coding tomorrow. Could you please ask John Feighery to take a look at https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/docs/README.md

2012/2/2 grassick < reply@reply.github.com

@pakdel I wrote a new algorithm to remove yellow lines by replacing green (G) and blue (B) with:

G * (1+lambda) - B * (lambda)

where lambda is calculated to minimize edges. Works great! Yellow lines go away completely!


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3779045

grassick commented 12 years ago

@pakdel Good to hear it! What piece are you planning to work on?

@rocketboy76 can you have a look at the table that Amir put together and make sure it's ok?

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/docs/README.md

rocketboy76 commented 12 years ago

Yes, thanks for reminding me about that. Here is a clarification about the types of colonies.

There are 3 general groups of bacteria that can be counted: -non-coliform bacteria. These are mostly gram negative bacteria but are not considered coliforms in this test because they do not ferment lactose to produce gas. They are mostly environmental bacteria and not associated with fecal contamination. -total coliform bacteria. These are bacteria that ferment lactose and produce gas, the classical definition of coliform bacteria. They include E. coli. They can be found naturally occurring in the environment but are often the result of fecal contamination. -E. coli. These are bacteria that are usually associated with fecal contamination as they are usually only found in the human intestinal tract. They produce the Beta-glucuronidase enzyme, which allows them to be differentiated from other total coliform bacteria (via the blue color change in Petrifilm)

Here is a hierarchical way to look at it:

                              gram negative bacteria                             => Red color change
                                     /                    \
                        non coliform             \                                        => No bubbles
                                                             \
                                                   total coliforms                        => bubbles around colony
                                                        /               \
                                               non-E. coli       \                          => red colonies with bubbles
                                       \
                                E. coli                     => blue colonies with bubbles

For example, if a Petrifilm result is 10 red colonies, 5 red colonies with bubbles, 5 blue colonies with bubble, the result recorded should be 5 other bacteria, 10 total coliform, and 5 E. coli. I hope this helps! Let me know if I can clarify this further.

Thanks, John

On Feb 3, 2012, at 9:01 AM, grassick wrote:

@pakdel Good to hear it! What piece are you planning to work on?

@rocketboy76 can you have a look at the table that Amir put together and make sure it's ok?

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/docs/README.md


Reply to this email directly or view it on GitHub: https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3797050

grassick commented 12 years ago

@pakdel. The most helpful thing to work on might be bubble detection. We still don't have a good algorithm for that. I would start with the fully normalized image with the yellow lines removed and work from there.

pakdel commented 12 years ago

Thanks John,

It seems that my counts are not correct. Would you please correct this list please: https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/docs/README.md

2012/2/3 rocketboy76 < reply@reply.github.com

Yes, thanks for reminding me about that. Here is a clarification about the types of colonies.

There are 3 general groups of bacteria that can be counted: -non-coliform bacteria. These are mostly gram negative bacteria but are not considered coliforms in this test because they do not ferment lactose to produce gas. They are mostly environmental bacteria and not associated with fecal contamination. -total coliform bacteria. These are bacteria that ferment lactose and produce gas, the classical definition of coliform bacteria. They include E. coli. They can be found naturally occurring in the environment but are often the result of fecal contamination. -E. coli. These are bacteria that are usually associated with fecal contamination as they are usually only found in the human intestinal tract. They produce the Beta-glucuronidase enzyme, which allows them to be differentiated from other total coliform bacteria (via the blue color change in Petrifilm)

Here is a hierarchical way to look at it:

                             gram negative bacteria
          => Red color change
                                    /                    \
                       non coliform             \
               => No bubbles
                                                            \
                                                  total coliforms
               => bubbles around colony
                                                       /

\ non-E. coli \ => red colonies with bubbles

\
                                                                   E.

coli => blue colonies with bubbles

For example, if a Petrifilm result is 10 red colonies, 5 red colonies with bubbles, 5 blue colonies with bubble, the result recorded should be 5 other bacteria, 10 total coliform, and 5 E. coli. I hope this helps! Let me know if I can clarify this further.

Thanks, John

On Feb 3, 2012, at 9:01 AM, grassick wrote:

@pakdel Good to hear it! What piece are you planning to work on?

@rocketboy76 can you have a look at the table that Amir put together and make sure it's ok?

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/docs/README.md


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3797050


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3797565

pakdel commented 12 years ago

Seems good to me. However, I think I should recreate a desktop app and continue from there (which should not take long)

2012/2/3 grassick < reply@reply.github.com

@pakdel. The most helpful thing to work on might be bubble detection. We still don't have a good algorithm for that. I would start with the fully normalized image with the yellow lines removed and work from there.


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3798452

pakdel commented 12 years ago

Hi everybody,

Since I did not receive any answer to my emails, I wanted to know whether you are still interested in continuing the development.

Thanks, Amir

Le 2 mars 2012 19:58, Amir Pakdel pakdel@gmail.com a crit :

@grassick I could not implement a good algorithm for calculation of lambda to be used in G * (1+lambda) - B * (lambda) Could you please post yours?

P.S. I am currently using lambda = 0.3 and it works relatively well.

Le 3 fvrier 2012 13:59, Amir Pakdel pakdel@gmail.com a crit :

Seems good to me. However, I think I should recreate a desktop app and

continue from there (which should not take long)

2012/2/3 grassick < reply@reply.github.com

@pakdel. The most helpful thing to work on might be bubble detection. We still don't have a good algorithm for that. I would start with the fully normalized image with the yellow lines removed and work from there.


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-3798452

cesine commented 12 years ago

hi pakdel ! yes we were cleaning to prepare to do some more development. are you coming next wednesday?

pakdel commented 12 years ago

Hi Gina,

I am coming next Wednesday. However, since we (Radialpoint) are performing a datacenter switch on that night, I might not be able to stay long.

Le 4 avril 2012 15:11, cesine < reply@reply.github.com

a crit :

hi pakdel ! yes we were cleaning to prepare to do some more development. are you coming next wednesday?


Reply to this email directly or view it on GitHub:

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/issues/33#issuecomment-4960748