Measuring length of DNA fibers from an image of single molecules I am a biologist with very little experience with image processing but have sufficient knowledge of MATLAB and have the image processing toolbox. Ideally I am looking for a MATLAB based solution, but an approach outlining how to go about it would also be helpful.

Update (28 Nov 2011)
It appears that there are certain problems (such as overlaps in signal and definition of color) when using composite images (which is what I presented in the initial question).  I am attaching separate images from the 2 channels: green  and red  (the turquoise regions in the composite image can be ignored), and the coposite image . The red channel is bad for 2 reasons: 1. It has poor contrast due to higher background, 2. Since Red seems to bleed into the green at the background level.  

A feature is defined as a region on the composite image that has
Green-Red-turquoise-Red-Green or equivalently the 2 adjacent linear segments on the green and the red that are colinear and contagious.

I am hoping that looking at the images from the two separate channels makes identification of the features easier.

I have the following suggestions for the algorithm:


First identify co-linear green segments (and determine lengths of the green segments)
Determine if there are adjacent contagious and colinear segments facing toward each other (i.e. green->red->  &lt;-red &lt;-green) in the red channel. If yes define the red segment length from the point where green segments end  (because they will overlap with the green segments) till the point on the red segment that is closest to the other red segment of the feature. (i.e. one of the ends of the red segment is set to the end of the overlapping green segment).


Many thanks!

Background:

My question relates to extracting feature from an image:



The original image (tif) is located here:


  Image example 1 (dropbox)


This image is a composite of 3 channels (in tif format): red, green and turquoise. The turquoise colored fibers simply marks all the DNA we have on the coverslip. The feature of interest is the Green-Red--turquoise--Red-Green feature on the single DNA strand that is the middle of the image. 

Red is generally the noisiest. This example is good because the contrast is good. However, sometimes the images are not so nice and there is hue throughout the image, so hard-coding a specific RGB value for the green and red color might not work for all images. Also, note that the fibers are not necessarily horizontal, they might be rotated (but never vertical). 

Please see this image for an example: 


The original image (tif) is located here:


  Image example 2 (dropbox) 


Also, sometimes a single image has many such features and sometimes there are multiple features on the same DNA strand. Finally sometimes there might be only partial features (i.e. isolated green or isolated red or isolated green-red segments, but unpaired). 

Question:

I would be grateful if someone can help me obtain the lengths of the individual segments of green and the red segments i.e. since the feature of interest is Green-Red--turquoise--Red-Green, each feature would have an array of 5 values (length of the first green segment, length of the first red segment, length of the turquoise segment, length of the second Red segment and the length of the second Green segment).
Example in Mathematica:

(* Get your image*)
img = Import["http://dl.dropbox.com/u/18072545/c_29.tif"];
(*Detect the extended minima and remove background*)
nB = ImageSubtract[img, ColorNegate@FillingTransform@ColorNegate[img]]  




(*Separate RGB channels*)
cS = ImageAdjust /@ ColorSeparate[img]


  

(*Binarize*)
bcS = Binarize[#, .4] &amp; /@ cS  


  

(*Remove large elements*)
tH = TopHatTransform[#, DiskMatrix[2]] &amp; /@ bcS  


  

(*Detect lines using a Hough Transform*)
lines = ImageLines[#, .01, .8] &amp; /@ tH
(*Plot them*)
Show[img, Graphics[{
   Thickness[.01], Red, Line /@ (lines[[1]]),
   Thickness[.006], Green, Line /@ (lines[[2]]),
   Thickness[.004], Blue, Line /@ (lines[[3]])}]]
(*Red and green are superimposed*)  




Edit

Here you may see the Red and Green clusters apart. As you can imagine, you have to decide when a portion is red!