I wondered how to get the value of histogram matching in adjust threshold. I can get the method with getMethod from threshold Adjuster, however I didn’t find a method to retrieve the option histogram matching.
Hello Philippe -
I’m not clear what you are asking about.
I’m using Fiji / ImageJ 153b5, and “adjust threshold” and “histogram
matching” seem to be two different things.
This appears to be the .getMethod() method of the
ThresholdAdjuster class that implements the
Image > Adjust > Threshold... menu command.
And this appears to be the “Histogram Matching” option of the
Image > Adjust > Bleach Correction menu command
that is implemented by the HistogramMatcher class.
As far as I can tell, these are two distinct implementations (that,
broadly speaking, perform somewhat similar operations).
What specifically are you trying to accomplish?
Sorry for the confusion I’m trying to get the value of option “stack histogram” (checked or not) in Adjust->Threshold menu. I would like to ask user to select a threshold method and apply to images in batch.
Hello Philippe -
Could I get a little more detail? Is this in the context of running an
ImageJ Macro (IJM)? A script? A java plugin?
If so, do you have a instance of the class
your code that you want to query, or has the user opened up a
ThresholdAdjuster window from the menu bar?
I’m guessing that you are looking for something like (non-existing)
ThresholdAdjuster.getStackHistogramValue() method (that
would be analogous to the (real)
method). Is this the basic idea?
Let’s say you had, somehow, “the value of option ‘stack histogram’.”
What would you then do with it? How does the specific value enter
into your (or your user’s) workflow?
I write a plugin (Java) in which I open the Adjust Threshold Dialog for the first image on the series, then I would keep the user selected parameters as threshold method (no problem) and if the user has checked or not the stack histogram option. This is to apply the same threshold method (not the values) to all images in the series.
Hello Philippe -
So, in java you have (a reference to) an instance of
ThresholdAdjuster does not fully expose the stack-histogram setting.
But from the code you can see there is package-private access to this
Specifically, this setting is encoded in a package-private
stackHistogram, whose state can be queried via its
method. You can also call the package-private method
boolean entireStack(ImagePlus imp), but this requires an
ImagePlus argument (and will return
imp is not a stack).
You can get past the package-private access restriction by writing a
helper class that you put in the
ij.plugin.frame package whose
job it is to query the stack-histogram setting for you. (This isn’t
so bad if you distribute your plugin in a jar – just include such a
helper class in the package directory tree in your jar.) You could
also use java reflection to bypass the package-private access
restriction. I would probably write the in-package helper class.
Another approach would be to open up your own
dialog box, and have your users enter the stack-histogram setting
that way. But this might be less familiar to your users.
Thanks for these infos. I think the simple way for me is to take the class ThresholdAdjuster in my plugin and bypass the private acces to the Checkbox stackHistogram.