0

I have been tasked with taking scanned images of a petri dish with bacterial colonies growing on it over time and performing an analysis of different statistics such as growth rate, time of appearance, etc. Thus far, I have taken the scanned image;

enter image description here

converted it to grayscale, ran it through a median filter, and thresholded it to arrive at this result;

enter image description here

The following snippet of code is my progress thus far:

# Reading image and gray scaling

test = skimage.io.imread("C:/Users/user/Documents/PythTestImg/img016.tif")
graytest = skimage.color.rgb2gray(test)

fig, ax = plt.subplots()
plt.imshow(graytest, cmap='gray')
plt.show()

# Median filter

d = disk(radius=2)
blurredtest = skimage.filters.median(graytest, d)

fig, ax = plt.subplots()
plt.imshow(blurredtest, cmap='gray')
plt.show()

# Histogram creation

histogram, bin_edges = np.histogram(blurredtest, bins=256, range=(0.0, 1.0))

fig, ax = plt.subplots()
plt.plot(bin_edges[0:-1], histogram)
plt.title("Grayscale Histogram")
plt.xlabel("grayscale value")
plt.ylabel("pixels")
plt.xlim(0, 1.0)
plt.show()

# Thresholding section

#t = skimage.filters.threshold_otsu(blurredtest)
#print("Found automatic threshold t = {}.".format(t))

t = 0.93
finaltest = blurredtest > t

fig, ax = plt.subplots()
plt.imshow(finaltest, cmap="gray")
plt.show()

This seems promising because I have completely isolated the bacterial colonies (shown in white) from the rest of the image; however, as you can see, there are some "false positives" on the perimeter of the circle that I need to remove, the big chunk of white on the perimeter more specifically. I have spoken with colleagues, and they suggested that I manually delete these values in the image matrix but this does not seem practical as my end goal is to process many images efficiently. Is there a way to selectively remove the perimeter while keeping the colonies intact? I am working on PyCharm using Python 3.11 with scikit-image for my image processing needs.

I have attempted to use hough transform functions and edge detection, but it does not find the correct parameters and returns the same result that I inputted to the functions. I am also confused about the input of parameters to these functions so that may be a reason for not being able to return what I want.

Bilal
  • 3,191
  • 4
  • 21
  • 49
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 19 '23 at 21:01
  • 1
    Without access to the original tiff, it is difficult to evaluate potential solutions. I would suggest uploading the image somewhere and providing a link, as for the other images. – Paul Brodersen Jun 23 '23 at 16:00

0 Answers0