Search code examples
imagej

ImageJ - how to ensure two images are directly comparable (what scripting command?)


I need to present some microscopy images side by side and ensure they are directly comparable by eye in a presentation. The pictures were all taken with the same exposures, gain et cetera so the underlying pixel values should be comparable.

However, the microscopy software has a nasty habit of saving the files with one of the colour channels saturated (for some reason), so I have to process the images for presentations.

Previously I'd been using a macro which processes through a folder and calls the scripting command

run("Enhance Contrast", "saturated=0.35");

But on reflection I don't think this is the proper command to call. I don't think it would produce images that are directly comparable, by eye, to each other.

I had thought that the command

run("Color Balance...");
resetMinAndMax();

would be best as it should show the full display range. But the display values shown on the histogram do vary depending on the image.

Is this appropriate for making directly comparable images or should I run a command like

setMinAndMax();

more appropriate. With 0 as minimum and an arbitrary figure as the maximum. This is driving me mad, as I keep on getting asked about whether my images are directly comparable but I simply don't know!


Solution

  • Usually, resetMinAndMax(); is the best way to ensure that your images are displayed consistently.

    Note however that it also depends on the bit depth of your images.

    • 8-bit grayscale images and RGB color images are displayed with a range of 0-255 upon resetMinAndMax();

    • For 16-bit (short) and 32-bit (float) images, the display range is calculated from the actual minimum and maximum values of the image (see the documentation of the Brightness/Contrast dialog and the resetMinAndMax() macro function)

    So for 16-bit and 32-bit images, you can use the Set Display Range dialog (Set button in the B&C window) with one of the default Unsigned 16-bit range options to ensure consistent display, or the macro call:

    setMinAndMax(0, 65535);
    

    If you want to use the images in a presentation, copy them using Edit > Copy to System, or convert them to either 8-bit or RGB before saving them and inserting them in a presentation.