I'm looking through a dataset set of images in ImageJ (a stack of .tif images, about 130 frames), and I have a problem with the dataset. It's a series of microscope images, with each frame being a plane about 3-4 micrometers above/below the previous one. As I go deeper into the dataset, light scattering makes for a brighter background, so the main features of the specimen are dimmer.
However, ImageJ's brightness and contrast feature uses a histogram that represents the entire stack of images. When I click "Auto" and "Reset" on an image deep in the stack, the resulting contrast is perfect: all the features light up really well. However, then, back at the start of the stack, most of the features have become saturated.
I've tried manually extracting a few images from various points in the stack and performing Auto->Reset in Brightness & Contrast on each one individually and re-converting them to a stack afterwards, and it looks really solid. How can I do this programmatically (e.g. with a plugin) for the entire stack? What are the relevant API calls?