How to get uniform background on phase-contrast images

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get uniform background on phase-contrast images

lechristophe
Hi,

I've captured a mosaic of 5x5 phase contrast images that I stitched with the
"Stitch Grid of Images" plugin. However, this revealed a problem of
non-uniform background on each tile and between tiles. This is not a
non-uniformity of the illumination, because it is dependent on the actual
objects in each image. The bright neurons on the image somehow illuminate
 the substrate around them, making the areas with cells much brighter than
the area without cells.

You can download the stack of individual, raw images here :
http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif

and a contrast-stretched, stitched mosaic image more demonstrative of the
problem :
http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif

How can I process the individual tile images to uniformize the illumination
across the whole mosaic ? I tried subtracting a large-kernel gaussian
blurred version of each tile, it works for getting uniform tiles, but it
somehow changes the contrast between cell-rich tiles and empty ones. It is
difficult to use a polynomial fitting of the background, as these method try
to reject the objects, and in my case the background comes form the objects.

If the microscopists among you see a simple modification at the acquisition
step that would also help (when recording the phase contrast image), don't
hesitate to tell me.

Thanks for your help,

Christophe


--
Christophe Leterrier
Postdoc
INSERM UMR641 // Ionic channels Lab
IFR Jean Roche, Mediterranée University
Marseille, France
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

G. Esteban Fernandez
How big was your Gaussian?  I thought it worked pretty well by
dividing images blurred with Gauss. radius of 20-50.  Better seams
with smaller radius but less contrast in objects.

-Esteban


On Fri, Oct 14, 2011 at 8:26 AM, Christophe Leterrier
<[hidden email]> wrote:

> Hi,
>
> I've captured a mosaic of 5x5 phase contrast images that I stitched with the
> "Stitch Grid of Images" plugin. However, this revealed a problem of
> non-uniform background on each tile and between tiles. This is not a
> non-uniformity of the illumination, because it is dependent on the actual
> objects in each image. The bright neurons on the image somehow illuminate
>  the substrate around them, making the areas with cells much brighter than
> the area without cells.
>
> You can download the stack of individual, raw images here :
> http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif
>
> and a contrast-stretched, stitched mosaic image more demonstrative of the
> problem :
> http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif
>
> How can I process the individual tile images to uniformize the illumination
> across the whole mosaic ? I tried subtracting a large-kernel gaussian
> blurred version of each tile, it works for getting uniform tiles, but it
> somehow changes the contrast between cell-rich tiles and empty ones. It is
> difficult to use a polynomial fitting of the background, as these method try
> to reject the objects, and in my case the background comes form the objects.
>
> If the microscopists among you see a simple modification at the acquisition
> step that would also help (when recording the phase contrast image), don't
> hesitate to tell me.
>
> Thanks for your help,
>
> Christophe
>
>
> --
> Christophe Leterrier
> Postdoc
> INSERM UMR641 // Ionic channels Lab
> IFR Jean Roche, Mediterranée University
> Marseille, France
> [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

Aryeh Weiss
In reply to this post by lechristophe
I think the following macro may help. It will cause all of the images to
have the same average intensity. It has a bunch of stuff specific to the
fact that my input was OIB images, so you will hav eot modify teh "front
end" a bit.

I used a very large low pass filter to estimate the mean, and then
renormalized the image to a mean of 128 (which you can change).

It also sets up an output directory and writes the normalized images
there. The you can stitch them. I think it will get rid of the seams in
your images.

//===================================

/* This macro will take a directory of dic images (which were presumably
tiled)
  *  flatten their background and then cause their average brightness to
be 128.
  *  This will make the ensuing stitching "seemless".
  *  The operations are:
  *  1 create a psuedo-backround with very strong averaging (mean with
radius 100)
  *  2. Divide original image by this average
  *  3. multiply result by 128/histogram_mean, so that the new average
is 128.
  */


sep="/";
  redChannel = "C1-";
  greenChannel = "C2-";
blueChannel = "C3-";

// blueChannel="*None*";
// grayChannel="*None*";
//redChannel = "*None*";
//greenChannel="*None*";
grayChannel="C3-";

run("Close All");

run("Bio-Formats Macro Extensions");
path = File.openDialog("Click on any image");

path_dir = File.getParent(path);
files_list=getFileList(path_dir);

output_dir = path_dir + sep + "dicFlat1";
if (File.exists(output_dir) == false) File.makeDirectory(output_dir);

setBatchMode(true);

for(i=0;i<files_list.length;i++){

if(endsWith(files_list[i], "oib")) {

path=File.getParent(path)+sep+files_list[i];
                Ext.openImagePlus(path);
                path_dir = File.getParent(path);
        fileName = File.getName(path);
    index = indexOf(fileName, ".");
        if (! isNaN(index)){
          new_filename =substring(fileName, 0, index);
        }

run("8-bit");
run("Split Channels");

redSelection = redChannel;
if (redSelection != "*None*") redSelection = redChannel + fileName;


greenSelection = greenChannel;
if (greenSelection != "*None*") greenSelection = greenChannel + fileName;

;
blueSelection = blueChannel;
if (blueSelection != "*None*") blueSelection = blueChannel + fileName;

graySelection = grayChannel;
if (graySelection != "*None*") graySelection = grayChannel + fileName;

selectImage(redSelection);
close();
selectImage(greenSelection);
close();

dicId = getImageID();
dicTitle = getTitle();
resetMinAndMax();

run("Duplicate...", "title=["+graySelection+"]");
bgId = getImageID();
bgTitle = getTitle();
run("Mean...", "radius=100");

imageCalculator("Divide create 32-bit", dicId, bgId);
dicNormId = getImageID();
dicNormTitle = getTitle();



run("8-bit");
resetMinAndMax();

getStatistics(area, mean, min, max, std, histogram);

brightnessFactor = 128/mean;
run("Multiply...","value="+d2s(brightnessFactor,2));

saveAs("ZIP", output_dir+"/"+new_filename+".zip");

run("Close All");

}
showProgress(i/files_list.length);
}
setBatchMode(false);


//================end of macro====================


Hope it helps.
--aryeh

On 10/14/11 5:26 PM, Christophe Leterrier wrote:

> Hi,
>
> I've captured a mosaic of 5x5 phase contrast images that I stitched with the
> "Stitch Grid of Images" plugin. However, this revealed a problem of
> non-uniform background on each tile and between tiles. This is not a
> non-uniformity of the illumination, because it is dependent on the actual
> objects in each image. The bright neurons on the image somehow illuminate
>   the substrate around them, making the areas with cells much brighter than
> the area without cells.
>
> You can download the stack of individual, raw images here :
> http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif
>
> and a contrast-stretched, stitched mosaic image more demonstrative of the
> problem :
> http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif
>
> How can I process the individual tile images to uniformize the illumination
> across the whole mosaic ? I tried subtracting a large-kernel gaussian
> blurred version of each tile, it works for getting uniform tiles, but it
> somehow changes the contrast between cell-rich tiles and empty ones. It is
> difficult to use a polynomial fitting of the background, as these method try
> to reject the objects, and in my case the background comes form the objects.
>
> If the microscopists among you see a simple modification at the acquisition
> step that would also help (when recording the phase contrast image), don't
> hesitate to tell me.
>
> Thanks for your help,
>
> Christophe
>
>
> --
> Christophe Leterrier
> Postdoc
> INSERM UMR641 // Ionic channels Lab
> IFR Jean Roche, Mediterranée University
> Marseille, France
> [hidden email]
>


--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

Gabriel Landini
On Saturday 15 Oct 2011 18:05:10 Aryeh Weiss wrote:
> I used a very large low pass filter to estimate the mean, and then
> renormalized the image to a mean of 128 (which you can change).
[..]
> brightnessFactor = 128/mean;
> run("Multiply...","value="+d2s(brightnessFactor,2));

Hi Aryeh,
I guess that this could be also done using an offset. Is it better to use a
factor in this kind of images?
Regards

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

Michael Schmid-3
In reply to this post by G. Esteban Fernandez
Hi Christophe,

you have bright and dark objects of different sizes and brightness  
levels, this makes background subtraction a bit difficult.

I'd try starting by duplicating the image and applying a median (r=20  
or so). Thereafter only a few bright objects remain.
Then you could continue with the built-in "Subtract  
Background" (sliding paraboloid, r=5, create background).

Add 1000 to your original (offset to enable negative values after  
subtraction) and subtract the background as created above.

The main drawback is that the median is quite slow. Maybe replacing  
the median by a sequence of alternating minimum and maximum filters  
would suffice (e.g. r=2 R=6 r=12 R=24 r=16, where r is for minimum  
and R for maximum; the sum of both should be equal).

Michael
________________________________________________________________



On Fri, Oct 14, 2011 at 8:26 AM, Christophe Leterrier
<[hidden email]> wrote:

> Hi,
>
> I've captured a mosaic of 5x5 phase contrast images that I stitched  
> with the
> "Stitch Grid of Images" plugin. However, this revealed a problem of
> non-uniform background on each tile and between tiles. This is not a
> non-uniformity of the illumination, because it is dependent on the  
> actual
> objects in each image. The bright neurons on the image somehow  
> illuminate
>  the substrate around them, making the areas with cells much  
> brighter than
> the area without cells.
>
> You can download the stack of individual, raw images here :
> http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif
>
> and a contrast-stretched, stitched mosaic image more demonstrative  
> of the
> problem :
> http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif
>
> How can I process the individual tile images to uniformize the  
> illumination
> across the whole mosaic ? I tried subtracting a large-kernel gaussian
> blurred version of each tile, it works for getting uniform tiles,  
> but it
> somehow changes the contrast between cell-rich tiles and empty  
> ones. It is
> difficult to use a polynomial fitting of the background, as these  
> method try
> to reject the objects, and in my case the background comes form the  
> objects.
>
> If the microscopists among you see a simple modification at the  
> acquisition
> step that would also help (when recording the phase contrast  
> image), don't
> hesitate to tell me.
>
> Thanks for your help,
>
> Christophe
>
>
> --
> Christophe Leterrier
> Postdoc
> INSERM UMR641 // Ionic channels Lab
> IFR Jean Roche, Mediterranée University
> Marseille, France
> [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

lechristophe
Hi Michael,

In fact the current implementation of my macro uses a large median
filter (50 pixel radius) on individual tiles. You're right it is slow,
but batching all mosaics from a macro makes it OK (I just leave it to
process all files).
As regards the rolling ball background procedure, I tried that but as
phase images alternate bright/dark/bright patterns and as my objects
are interwined processes of neuronal cells, the result was not very
good.
That said, the median procedure produces much better results than
gaussian filtering so I'm quite pleased with the current solution.

Thanks for your thoughts,

Christophe

PS/
I would also like to thank all the people that answered to my
question, either on the list or privately. Using your advices I think
I now have a good procedure for preprocessing and stitching
multi-channel mosaics. You can check the macro I wrote here in case it
could be useful for you:
https://github.com/cleterrier/IJ-macros/blob/master/WIP/Stitch_Processed_Mosaic.ijm

- I start from a folder filled with individual images (made on
Axiovision by saving the mosaic image as .tif format, which outputs a
_File folder containing the individual tiles as tif).
- I import these images as a stack, then process them with wathever I
want (for the moment background subtraction, hence my question)
- Then export this stack as individual images a new folder
- Launch the stitch plugin form the macro using the right parameters
There is more code in the macro:- it automatically detects the size of
the mosaic (if it is square) and the number of channels.- the
stitching is made on the channel chosen as reference and the
coordinates of this stitching are used to stitch the other channels.
This is done by copying the output txt file of the reference channel
stitching, changing the channel reference strings in it, and feed it
to another stitch plugin called "Stitch Collection of Images" but with
the option of not to compute but to stitch according to the reference
ouptut file.




On Mon, Oct 17, 2011 at 17:30, Michael Schmid <[hidden email]> wrote:

> Hi Christophe,
>
> you have bright and dark objects of different sizes and brightness levels,
> this makes background subtraction a bit difficult.
>
> I'd try starting by duplicating the image and applying a median (r=20 or
> so). Thereafter only a few bright objects remain.
> Then you could continue with the built-in "Subtract Background" (sliding
> paraboloid, r=5, create background).
>
> Add 1000 to your original (offset to enable negative values after
> subtraction) and subtract the background as created above.
>
> The main drawback is that the median is quite slow. Maybe replacing the
> median by a sequence of alternating minimum and maximum filters would
> suffice (e.g. r=2 R=6 r=12 R=24 r=16, where r is for minimum and R for
> maximum; the sum of both should be equal).
>
> Michael
> ________________________________________________________________
>
>
>
> On Fri, Oct 14, 2011 at 8:26 AM, Christophe Leterrier
> <[hidden email]> wrote:
>>
>> Hi,
>>
>> I've captured a mosaic of 5x5 phase contrast images that I stitched with
>> the
>> "Stitch Grid of Images" plugin. However, this revealed a problem of
>> non-uniform background on each tile and between tiles. This is not a
>> non-uniformity of the illumination, because it is dependent on the actual
>> objects in each image. The bright neurons on the image somehow illuminate
>>  the substrate around them, making the areas with cells much brighter than
>> the area without cells.
>>
>> You can download the stack of individual, raw images here :
>> http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif
>>
>> and a contrast-stretched, stitched mosaic image more demonstrative of the
>> problem :
>> http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif
>>
>> How can I process the individual tile images to uniformize the
>> illumination
>> across the whole mosaic ? I tried subtracting a large-kernel gaussian
>> blurred version of each tile, it works for getting uniform tiles, but it
>> somehow changes the contrast between cell-rich tiles and empty ones. It is
>> difficult to use a polynomial fitting of the background, as these method
>> try
>> to reject the objects, and in my case the background comes form the
>> objects.
>>
>> If the microscopists among you see a simple modification at the
>> acquisition
>> step that would also help (when recording the phase contrast image), don't
>> hesitate to tell me.
>>
>> Thanks for your help,
>>
>> Christophe
>>
>>
>> --
>> Christophe Leterrier
>> Postdoc
>> INSERM UMR641 // Ionic channels Lab
>> IFR Jean Roche, Mediterranée University
>> Marseille, France
>> [hidden email]
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

Jerry (Gerald) Sedgewick
In reply to this post by Michael Schmid-3
I've always had good results using the High Pass filter with a Radius of 200
or so.  It does not remove any detail on the phase images, but removes
uneven background.

Jerry

On Mon, Oct 17, 2011 at 10:30 AM, Michael Schmid <[hidden email]>wrote:

> Hi Christophe,
>
> you have bright and dark objects of different sizes and brightness levels,
> this makes background subtraction a bit difficult.
>
> I'd try starting by duplicating the image and applying a median (r=20 or
> so). Thereafter only a few bright objects remain.
> Then you could continue with the built-in "Subtract Background" (sliding
> paraboloid, r=5, create background).
>
> Add 1000 to your original (offset to enable negative values after
> subtraction) and subtract the background as created above.
>
> The main drawback is that the median is quite slow. Maybe replacing the
> median by a sequence of alternating minimum and maximum filters would
> suffice (e.g. r=2 R=6 r=12 R=24 r=16, where r is for minimum and R for
> maximum; the sum of both should be equal).
>
> Michael
> ______________________________**______________________________**____
>
>
>
> On Fri, Oct 14, 2011 at 8:26 AM, Christophe Leterrier
> <christophe.leterrier@gmail.**com <[hidden email]>> wrote:
>
>> Hi,
>>
>> I've captured a mosaic of 5x5 phase contrast images that I stitched with
>> the
>> "Stitch Grid of Images" plugin. However, this revealed a problem of
>> non-uniform background on each tile and between tiles. This is not a
>> non-uniformity of the illumination, because it is dependent on the actual
>> objects in each image. The bright neurons on the image somehow illuminate
>>  the substrate around them, making the areas with cells much brighter than
>> the area without cells.
>>
>> You can download the stack of individual, raw images here :
>> http://www.cleterrier.net/up/**phase-5x5-10%25-rawTiles.tif<http://www.cleterrier.net/up/phase-5x5-10%25-rawTiles.tif>
>>
>> and a contrast-stretched, stitched mosaic image more demonstrative of the
>> problem :
>> http://www.cleterrier.net/up/**phase-5x5-10%25_mosaic.tif<http://www.cleterrier.net/up/phase-5x5-10%25_mosaic.tif>
>>
>> How can I process the individual tile images to uniformize the
>> illumination
>> across the whole mosaic ? I tried subtracting a large-kernel gaussian
>> blurred version of each tile, it works for getting uniform tiles, but it
>> somehow changes the contrast between cell-rich tiles and empty ones. It is
>> difficult to use a polynomial fitting of the background, as these method
>> try
>> to reject the objects, and in my case the background comes form the
>> objects.
>>
>> If the microscopists among you see a simple modification at the
>> acquisition
>> step that would also help (when recording the phase contrast image), don't
>> hesitate to tell me.
>>
>> Thanks for your help,
>>
>> Christophe
>>
>>
>> --
>> Christophe Leterrier
>> Postdoc
>> INSERM UMR641 // Ionic channels Lab
>> IFR Jean Roche, Mediterranée University
>> Marseille, France
>> christophe.leterrier@univmed.**fr <[hidden email]>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: How to get uniform background on phase-contrast images

Aryeh Weiss
In reply to this post by Gabriel Landini
On 10/17/11 4:59 PM, Gabriel Landini wrote:

> On Saturday 15 Oct 2011 18:05:10 Aryeh Weiss wrote:
>> I used a very large low pass filter to estimate the mean, and then
>> renormalized the image to a mean of 128 (which you can change).
> [..]
>> brightnessFactor = 128/mean;
>> run("Multiply...","value="+d2s(brightnessFactor,2));
>
> Hi Aryeh,
> I guess that this could be also done using an offset. Is it better to use a
> factor in this kind of images?
> Regards
>
> Gabriel
>
>
>
>

Hi Gabriel,

You are correct -- I simply did not think of using an offset. However, I
note that the multiplicative factor keeps the low values low, so it may
preserve contrast better.

Best regards,
--aryeh
--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051