Colocalizing colors in an image

18 views (last 30 days)
cjb b
cjb b on 10 Jun 2013
I am working with fluorescent images in which I am capturing the nuclei in blue and the cell body of a neuron in red. They both appear to be ball-like in structure. We know that the two colocalize and we also know that if we they don't, then the nuclei then it is something else.
What I would need to do is to compare the two channels and produce a new image in which only the colocalized pixels remain. Nuclei not associated with neurons would then be removed. I would also like to maintain the variation in the pixel intensity but this is not an absolute. If we can get this to work, it will dramatically increase our ability to perform cell counts quickly and accurately using an automated counts program we wrote for matlab, which we plan on sharing with the larger science community.
Any suggestions?

Accepted Answer

Jeff E
Jeff E on 11 Jun 2013
The approach I would take would be to create 2 binary masks that identify each of the signals from their respective fluorescent channels. You can do this any way you like, but setting a global threshold followed by morphological filtering is a pretty standard approach. At that point, you can use IMRECONSTRUCT to identify cell nuclei that contain your neuronal marker. For example:
marker = nuclei_mask & neuron_mask ;
colocalized_mask = imreconstruct(marker, nuclei_mask) ;
This would give you the nuclear mask of cells that contain your neuronal marker. Depending upon what your images look like, you might want to do some filtering of your marker image before reconstruction.
If you post some example images, that would go a long way to receiving helpful advice...
  4 Comments
Jeff E
Jeff E on 12 Jun 2013
Below is some code that should at least get you started. The actual segmentation of the cell nuclei is not all that great, but can be switched out to something more accurate. You may also need to play around with some of the threshold values and size of the kernels (i.e. d20 = circle of radius = 20) depending upon what your other images look like.
As an aside, if you have access to a confocal, I would recommend trying that out. Many of the cell nuclei are out of the focal plane, and some are overlapping other neighboring cells. This poor focus and close proximity will reduce the accuracy of most segmentation approaches I know of.
imgin = imread('n_n.tif'); % read in image
imgblue = imgin(:,:,3) ; % blue, nuclei only signal
imgred = imgin(:,:,1) ; % red, neuron only signal
d100 = strel('disk', 100);
d4 = strel('disk', 4);
d20 = strel('disk', 20);
d10 = strel('disk', 10);
d7 = strel('disk', 7);
%%all DAPI cell count
imgblue_T = imtophat(imgblue, d100); %background correction
int_mask = (imgblue_T > 30) ; % creates intensity mask, restricted to dapi positive area
int_mask2 = imclose(int_mask, d4); % removes small holes in nucleur mask
int_mask2 = ~bwareaopen(~int_mask2, 100); %removes objects below cutoff
intent2 = imopen(imgblue, d20); %blurs image
intent2o = intent2;
intent2(~int_mask2) = 0; % remove areas that do not meet intensity thresholds
intentC = imopen(intent2, d10); % flattens peaks. cells below kernel size are removed
maxima = imregionalmax(intentC, 8); % finds maxima associated with flattened peaks
maximaN = maxima & int_mask2; % ensures maxima fall entirely within positive mask, needed to reconstruct
reconD = imreconstruct(maximaN, maxima); % final cell markers
%%Find red positive cells
r_sub = imtophat(imgred, d100); %background correction
r_pos = r_sub > 50; %mask for red positive areas
r_posC = imclose(r_pos, d7); %consolidate positive mask
rb_coloc = r_posC & reconD; %Find overlap with nuclei mask
rb_colocO = bwareaopen(rb_coloc, 200); %remove small objects
reconFT = imreconstruct(rb_colocO, reconD); %mask of cells co-localizing DAPI and neuronal marker
cjb b
cjb b on 26 Jun 2013
Thanks for all your help.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 10 Jun 2013
Perhaps you can do color classification in RGB space or hsv color space. See my File Exchange. Otherwise use kmeans clustering. http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html
  1 Comment
Image Analyst
Image Analyst on 12 Jun 2013
After looking at your image's 3D color gamut, you don't have an image that has a bimodal distribution and is easily separable so that you can use single planes to classify the colors. It's more of a continuum rather than a bimodal distribution so you're going to have to make some judgement calls. I looked at RGB space, HSV space, and LAB space and it looks like the best bet would be to threshold on the hue channel. See my hsv color classification demo in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!