Thresholding pictures with strong background?

Dear community,

my lab-mate and I have the following problem: We want to threshold some IHC§ pictures and analyse the total amount of Collagen 1. Our antibodies are not that specific, we tried several techniques. We clearly see the Collagen (because it is “sharp”) but it has the same pixel-value as some background-regions (so thresholding is not possible/right). Is there a way to first highlight these “sharp” regions and then turn everything into black (except the sharp region, it should be white then)?

Thanks for any advice and tip!

Hi Hanna,

Welcome to the forums!

Could you add some arrows to indicate what you are labelling as ‘sharp’ in the image?



Hey Rob, thanks for the quick answer!
Here are 2 pictures with Collagen 1 highlighted (with paintbrush)

I know, there will be still unspecific spots, but that would be fine. Is it somehow possible to catch and threshold the paintbrushed area(s) (of course without paintbrush-style :wink: )?
Thank you!

Good day Hanna,

not sure if you’ve acquired the images yourself but I highly recommend a higher spatial resolution, at least a factor of two.

Furthermore, your sample images suffer from JPG-artifacts. Please post PNG-images of the original images (not of the JPG ones of course).

A final question concerns the two initially posted sample images.
What is the exact difference (what kind of sharpening operation)?



Hi Herbie,

thank you for your answer and sorry for the misunderstandings!
Here is the original picture (just converted to red) as PNG.
Here the picture after 3 times Process>Sharpen. In my opinion, my areas of interest are now more visible than before (yeah, there is a loss of data).
I guess, the camera and program of our microscope works at its best, if it’s possible to increase the spatial resolution, i’ll fix it, thanks for the tip!
I am not sure, if I am on the right way to catch my area of interest (maybe I see it clearly in the picture because I know where it is and should be) …

Hi Hanna,

I tried to remove most of the ‘fuzzy’ signal using subtract background (Process > Subtract Background…) with a 1 or 2 pixel rolling ball radius. The result helped with thresholding the ‘sharp’ borders in your image, but obviously wouldn’t be possible to get the entire border from a threshold.

Result from subtract background:


Result from thresholding top 1.2% of pixels:


1 Like

Hi 7rebor,

thanks for your advice and sorry for the question then - we tried this function but did not get the idea of testing smaller pixel values like 1.2 … :see_no_evil:

This is great!

I agree with Herbie that these images are not the best that they could be.

I would be careful that these ‘sharp’ borders are not just non-specific antibody binding, have you tried control sections with no primary antibody staining? The large degree of background fluorescence is frustrating, if this is fluorescence IHC, is it possible you can use a different secondary antibody with a fluorophore that is separate from the background fluorescence. And also a filter for your microscope that would better separate the two emission wavelengths?

Alternatively, have you tried your collagen-1 antibody on cultured fibroblast cells (these produce a lot of collagen?) instead, to see what ideal staining might look like with the antibody in question.


Thanks for all the advices! We are going to improve our techniques :slight_smile:

1 Like

Hi @hanna93,

I agree with @anon96376101 and @7rebor that it will pay off to first improve your image quality by:

  • improving the staining (check antibody specificity, use negative controls), and
  • optimizing the acquisition (higher optical resolution by using higher magnification/higher NA objective).

This applies if the background fluorescence is due to auto-fluorescence in your tissue. If there’s unspecific binding of your antibodies in the cytoplasm, you’ll have to work on improving the staining procedure (more rigorous washing etc.)

Regarding the analysis, I’d like to add another suggestion. I quickly tried using Trainable Weka Segmentation on your png image. I was drawing the following traces to define foreground (collagen) and background (everything else) (after switching the LUT to Grays for visibility):

With the following settings:

I got this probability map (the brighter the intensity, the more “likely” it is classified as your class of interest by the trained classifier:


You might want to try improving this by training on more images (and of course, the better the images you feed in, the better the segmentation result will be).


Well Hanna,

these images are already much better but slightly higher resolution would help further.

Here is what I get without any processing (no sharpening, no shading correction):

I think Variance-filtering with size = 1 is not that bad.
Of course, with preceding shading etc. the results will be even better.



1 Like

@anon96376101 @imagejan @7rebor Again thank you a lot for helping and testing other methods! You helped us a lot!

1 Like