|Sample DNA Image|
This is a proof of concept (POC) developed using Python3, NumPy, and OpenCV, to count and label the number of DNA strands from an image of combed DNA molecules.
The technique of Adaptive Mean Thresholding is used here.
There are several Thresholding algorithms available.
Global Thresholding will not apply here as the image has different lighting conditions in different areas.
Adaptive Mean Thresholding calculates a threshold value for small regions of the image. This gives us different threshold values for different areas of the image, which give better results.
There are two approaches for this:
- Mean Thresholding - threshold value is the mean of the surrounding area
- Gaussian Thresholding - threshold value is the weighted sum of values of surrounding areas
An example can be seen on OpenCV website. The example image clearly shows the difference:
|Source: OpenCV website|
In this case, Adaptive Mean Thresholding was giving better results than Adaptive Gaussian Thresholding.
The intermediate image produced after thresholding looked like:
|Image after thresholding|
We ignored the smaller contours and focused on the larger ones. Redrawing contours on another image and labeling them resulted in the following image:
|Image after adding labels|
The source code, sample images, and Jupyter Notebook is available in the GitHub Repository.