Reducing / Enhancing known features in an image

347 Views Asked by At

I am microbiology student new to computer vision, so any help will be extremely appreciated.

This question involves microscope images that I am trying to analyze. The goal I am trying to accomplish is to count bacteria in an image but I need to pre-process the image first to enhance any bacteria that are not fluorescing very brightly. I have thought about using several different techniques like enhancing the contrast or sharpening the image but it isn't exactly what I need.

I want to reduce the noise(black spaces) to 0's on the RBG scale and enhance the green spaces. I originally was writing a for loop in OpenCV with threshold limits to change each pixel but I know that there is a better way.

Here is an example that I did in photo shop of the original image vs what I want.

Original Image and enhanced Image.

I need to learn to do this in a python environment so that I can automate this process. As I said I am new but I am familiar with python's OpenCV, mahotas, numpy etc. so I am not exactly attached to a particular package. I am also very new to these techniques so I am open to even if you just point me in the right direction.

Thanks!

3

There are 3 best solutions below

3
On BEST ANSWER

I initially tried histogram equalization but did not get the desired results. So I used adaptive threshold using the mean filter:

th = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 3, 2) enter image description here

Then I applied the median filter:

median = cv2.medianBlur(th, 5) enter image description here

Finally I applied morphological closing with the ellipse kernel:

k1 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
dilate = cv2.morphologyEx(median, cv2.MORPH_CLOSE, k1, 3)

THIS PAGE will help you modify this result however you want.

1
On

You can have a look at histogram equalization. This would emphasize the green and reduce the black range. There is an OpenCV tutorial here. Afterwards you can experiment with different thresholding mechanisms that best yields the bacteria.

0
On

Use TensorFlow:

  1. create your own dataset with images of bacteria and their positions stored in accompanying text files (the bigger the dataset the better).
  2. Create a positive and negative set of images
  3. update default TensorFlow example with your images
  4. make sure you have a bunch of convolution layers.
  5. train and test.

TensorFlow is perfect for such tasks and you don't need to worry about different intensity levels.