Remove overlap spots



Hello forum,

I have two kinds of spots, green and red. Sometimes they are overlapped. How can I remove overlapped spots?
I want to analyze the green spots alone.
I will grateful if anyone can help me with this problem.



Good day Parinaz,

it would be helpful to see a typical raw image in the original TIF- or PNG-format. No JPG-format though, because JPG introduces artifacts! You may also post images as Zip-archives.

If your staining/marking is red and green and you deal with RGB-images, you could try "“Image >> Color >> Spli Channels”.




Parinaz ,
As Herbie suggested use the “split channels” but you will have to process them further to fully get rid of the overlap areas, otherwise there will still be overlap areas just spread over all three channels. I await your sample images.


Dear @Herbie and @smithrobertj

Thank you for your answer. Here is one of my image in PNG format.
Actually, half of the green spots are supposed to appear next to the red spots. I want to remove these spots and keep the other half of green spots.



Good day,

it appears as if you’ve converted a JPG-compressed image to PNG. This is not an acceptable approach, because JPG-compression introduces artifacts that can’t be removed and that remain if you convert such images to an uncompressed format.

As I’ve written, please post a typical raw image in the original TIF- or PNG-format.

Furthermore the spatial resolution of your sample image is poor annd why did you show us an image with large empty area?

Finally, please tell us if you want to remove the overlapping dots, even if the overlap is partial, or if you only want to remove the overlapping part, i.e. the yellow part, of the dots.




Are the blobs binary? If so you could use morphological reconstruction to identify in image A the blobs that overlap with those on image B.


You only have to split the channels, then subtract BOTH the red and blue channels from the green channel. The yellow spots are caused by the red channel overlapping the green channel.


No, what you suggest only removes the overlapping sub-region, not the overlapping blobs. Some blobs only partially overlap.
You could use Region Connection Calculus
but it is overkill for this application that can be resolved with just the morphological reconstruction.


Take your pick.


Hi @Herbie

My original image is in TIF format. I couldn’t upload them here, so I uploaded the PNG one. Is it the right format or there is still a problem??? :thinking:

As I showed in following images, I want to remove the overlapping dots not yellow part of dots. In the third image, I’ve removed them manually.



Thank you so much Bob, @smithrobertj. But I think I didn’t explain my aim well. I want to remove both red and green dots which are close together, not only the overlapping area. My analysis must be done on the green dots which are not attached to the red ones.
Actually, these dots represent the location of two ends of chromosomes. One end expresses both red and green protein while another one expresses only the green protein, and I need the later one.



Dear @gabriel

Thank you for your suggestion. Is it a plugin in Image J??



If you use Fiji, add the Morphology update site (the plugin is called Binary_Reconstruction under Plugins>Morphology after installation). If you use ImageJ you can download it the Morphology collection (a zip file that you need to expand in the plugins folder) from here:


Good day Parinaz,

your sample image is dramatically over-exposed in the green and red channel.
Is this intended or caused by lack of control during image acquisition or did you do some image pre-processing?

In any case I shall have a look at the data.



Why don’t you post the original “.lif”-files as a ZIP-archive?



here is an ImageJ-macro that should do what you want:

// imagej-macro "chromosomes" (Herbie G., 07. Nov 2018)
requires( "1.52h" );
run("Set Measurements...", "centroid redirect=None decimal=1");
setForegroundColor(0, 0, 0);
run("Duplicate...", "title=temp");
run("Split Channels");
selectImage("temp (red)");
imageCalculator("AND", "temp (red)", "temp (green)");
run("Analyze Particles...", "add");
roiManager("multi-measure measure_all");
close("temp (red)");
close("ROI Manager");
for ( i=0; i<x.length; i++ ) { 
   doWand(floor(x[i]), floor(y[i]));
   getSelectionBounds(xx, yy, w, h);
   if (h!=getHeight()) run("Fill", "slice");
run("Select None");
function makeBinary() {
   setOption("BlackBackground", true);
   setAutoThreshold("Intermodes dark");
   run("Convert to Mask");
// imagej-macro "chromosomes" (Herbie G., 07. Nov 2018)

Paste the above macro code to an empty macro window (Plugins >> New >> Macro) and run it with your RGB-image open in ImageJ.

Here is what i get:

Please note that the resulting images are always binary!




I highly recommend using the free Cell Profiler software (part of this message board). It has an intuitive built in function for turning your spots into objects. You can then relate your red and green objects and filter out the ones than have any overlap. If it’s necessary to analyze your original image minus the overlap, you could use the overlapped objects to create a mask. The software has an intuitive layout and is flexible for other applications, so learning how to use it is well worth the time. Steve


Dear @Herbie

Thank you sooooooo much for the macro code. It worked. :slight_smile: :ok_hand: :rose: :rose: :rose:



Thank you Gabriel. The code that Herbie sent worked, but I will try this plugin too. :rose:



Hi @Steve1

Thanks for your complete response. :rose:



If you decide to try Cell Profiler let me know and I can try to help out. I’m pretty new to the software but have been very impressed so far and appreciate it’s flexibility and potential.