imagej / imagej2

Open scientific N-dimensional image processing :microscope: :sparkler:
https://imagej.net/
BSD 2-Clause "Simplified" License
1.19k stars 333 forks source link

What method is called on the "Apply" button? #244

Closed loomcode closed 4 years ago

loomcode commented 4 years ago

From the GUI I can use Image->Adjust->Brightness/Contrast tool. When I click, "Apply", the scale is stretched between 0-65553 (for a 16 bit image).. How can I do this in the Java API? I can set min/max on an ImagePlus or ImageProcessor, but I don't know how to change the scale so that the lowest value is zero.

More broadly, how do I apply changes in general to the image pixel array? If I use setMinAndMax(100, 1000) then getMin() and getMax() reflect the changes, but they aren't applied to the image if I save it to disk.

loomcode commented 4 years ago

I think the answer is here: https://github.com/imagej/imagej/issues/141

Is this somewhere in the documentation?

imagejan commented 4 years ago

I don't think #141 is in any way related, as that issue is dealing with synchronization of properties between ImageJ2 (this repository) and ImageJ1.x.

You are asking about the Brightness&Contrast plugin, which is a pure ImageJ 1.x plugin implemented here:

https://github.com/imagej/imagej1/blob/f0390e8c225dd2c61f9913bed7a6ec9212b3fcdd/ij/plugin/frame/ContrastAdjuster.java

How can I do this in the Java API?

The best way to find out is running the macro recorder (Plugins > Macros > Record...) in Java mode:

IJ.run(imp, "Apply LUT", "");

See also the documentation of the tool here: https://imagej.net/docs/guide/146-28.html#sub:Brightness/Contrast...[C]


In general, please ask questions about ImageJ usage and API on https://forum.image.sc/tags/imagej