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 enter image description here and red enter image description here (the turquoise regions in the composite image can be ignored), and the coposite image enter image description here. 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:

  1. First identify co-linear green segments (and determine lengths of the green segments)

  2. Determine if there are adjacent contagious and colinear segments facing toward each other (i.e. green->red-> <-red <-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!


My question relates to extracting feature from an image:

enter image description here

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:

enter image description here 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).


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).

  • 3
    $\begingroup$ Hello, this question is about to be migrated to Signal Processing. Our focus is on image processing and algorithms, and I've edited your question to ask for that. Although there might be people knowledgable in MATLAB, you might get solutions in other languages (or pseudocode), which will guide you to the answer. If you're still stuck in implementing the solution in MATLAB (assuming you haven't gotten a MATLAB answer already), you can always come back to Stack Overflow to ask for help in translating. $\endgroup$ – Lorem Ipsum Nov 26 '11 at 17:59
  • $\begingroup$ A first step should be to store each signal in its independent channel. Yes, CFP is turquoise, but you shouldn't have to unmix its signal from the green channel. $\endgroup$ – Jonas Nov 26 '11 at 20:23

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]]  

enter image description here

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

enter image description here

bcS = Binarize[#, .4] & /@ cS  

enter image description here

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

enter image description here

(*Detect lines using a Hough Transform*)
lines = ImageLines[#, .01, .8] & /@ 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*)  

enter image description here


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

enter image description here

| improve this answer | |
  • $\begingroup$ Many thanks for your answer. I am not clear what the blue line is suppose to represent as there is only one feature in this image. Is it possible to get the lengths of just the red and green segments on the line where you have superimposed red/green?. $\endgroup$ – Lee Sande Nov 27 '11 at 14:46
  • 1
    $\begingroup$ @Lee Of course it is possible! Once you have the Hough transform, use the dilated line as a mask and measure nearby red points. $\endgroup$ – Dr. belisarius Nov 27 '11 at 15:20
  • $\begingroup$ @Lee The only think to care about is having a good definition of "red" :) $\endgroup$ – Dr. belisarius Nov 27 '11 at 16:07
  • $\begingroup$ @Lee If you have access to Mathematica, I could post some more code to separate the segments $\endgroup$ – Dr. belisarius Nov 27 '11 at 16:53
  • $\begingroup$ Many thanks for your response. I realized from your response that the red channel is problematic and the signal overlapping the adjacent green segment would have to be truncated. I have updated the problem--could you please take a look and tell me if it makes sense? $\endgroup$ – Lee Sande Nov 28 '11 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.