Skip to main content

Count and Label DNA strands

Sample DNA Image
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:
  1. Mean Thresholding - threshold value is the mean of the surrounding area
  2. 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:
Thresholding sample from OpenCV site
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
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 with Labels
Image after adding labels
The source code, sample images, and Jupyter Notebook is available in the GitHub Repository.
Happy Coding!
- Vivek

Comments

Popular posts from this blog

Assembla hit by a virus?

Today hosted task management site Assembla was hit by some virus. Around 3 hours back we got Service Unavailable - DNS failure error when trying to access the portal.
Trying to call any API from Assembla returns with the following unwanted HTML code prepended to the response:
<html><head><meta http-equiv="refresh" content="0; URL=http://sedoparking.com/?path=home"></head><body><a href="http://sedoparking.com/?path=home">Please click here</a></body></html>
We have logged a ticket with them. The response was quick but when we tried to post a reply comment we consistently got error - Your CAPTCHA words didn't match We'll keep on chasing them for updates and hope safety for Assembla users.

- Vivek

Of Imitation, Innovation, Inspiration and Improvisation

Copy-paste was never easier, thanks to modern technology. Ideas and innovations now spread even faster. When a product is launched in the market, within a few days, we have other vendors with a similar offering. The case is more severe with mobiles and tablets.