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 the circle of the petri-film #17

Closed pakdel closed 12 years ago

pakdel commented 12 years ago

Filter out what is outside the inner circular transparent film.

def findcircle(img):
    # Gray scale and blur
    gray=cv2.cvtColor(img, cv.CV_BGR2GRAY)
    blur=cv2.GaussianBlur(gray, (5, 5), 0)

    # Get min max radius
    h, w = img.shape[:2]
    minrad=min(h,w)/8
    maxrad=min(h,w)/2
    circles=cv2.HoughCircles(blur, cv.CV_HOUGH_GRADIENT, 2, 100, None, 100, 100, minrad, maxrad)

    return (circles[0][0][0],circles[0][0][1],circles[0][0][2])

https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/data/stage1.png https://github.com/AndroidImageProcessing/AndroidBacteriaImageProcessing/blob/master/data/stage2.png