Dear Michael, Thanks a lot for your answer! Given that I'm only changing the applied method and not modifying the "dark background" state, your proposed solution is solving my issue. So thanks a lot! I had found the ij.plugin.frame.ThresholdAdjuster.setMethod but missed (i.e. had forgotten) the macro call method. Have a nice weekend, Philippe
----- Mail original ----- De: "Michael Schmid" <[email protected]> À: "imagej" <[email protected]> Envoyé: Jeudi 11 Janvier 2024 18:36:54 Objet: Re: setAutoThreshold through macro code Hi Philippe, ok, now I understand the problem. The reason why the ThresholdAdjuster panel does not show the method is that the two commands setAutoThreshold("Otsu dark"); and run("Threshold..."); are unrelated. The ThresholdAdjuster panel knows nothing about the previous operation since the macro command setAutoThreshold is not via the gui. Fortunately, the ThresholdAdjuster class has a public static method public static void setMethod(String thresholdingMethod) It can be used to set the method and update the displayed method. You can call it from a macro with, e.g. call("ij.plugin.frame.ThresholdAdjuster.setMethod", "Otsu"); If you call this method together with the setAutoThreshold("Otsu"), the ThresholdAdjuster panel will show the correct method. There is no similar method for the "dark background" flag. As far as I can say, you can't set that checkbox from a macro while the ThresholdAdjuster panel is open. You can only set the state of the "dark background" flag *before* you open the ThresholdAdjuster panel with the following trick: call("ij.Prefs.set", "threshold.dark", "true"); Michael ________________________________________________________________ On 11.01.24 15:35, CARL Philippe (LBP) wrote: > Hi Michael, > Sorry if my text wasn't clear enough and I confirm that "command does update > the histogram display" (as I wrote "As the min and max levels seem to be > updated"). > The issue is that the method name doesn't get updated within the > "Threshold..." window. > Thus a user can't know "which" or "if" a given method had been set by the > macro code. > Kindest regards, > Philippe > > ----- Mail original ----- > De: "Michael Schmid" <[email protected]> > À: "imagej" <[email protected]> > Envoyé: Jeudi 11 Janvier 2024 15:25:01 > Objet: Re: setAutoThreshold through macro code > > Hi Philippe, > > as far as I can see, the run("Threshold...") command does update the > histogram display. You won't see much difference with the Blobs sample > and these thresholding methods because they all yield essentially the > same threshold. If you use a different image like the M51 galaxy sample, > you can better see it. > > Michael > ________________________________________________________________ > On 11.01.24 14:23, CARL Philippe (LBP) wrote: >> Dear all, >> Isn't it possible to perform a setAutoThreshold within a macro and visualyze >> this selection within the Threshold... window ? >> As the min and max levels seem to be updated, it is not the case of the >> threshold method as illustrated by the following small macro code: >> run("Blobs (25K)"); >> setAutoThreshold("Otsu dark"); >> run("Threshold..."); >> waitForUser; >> setAutoThreshold("Minimum dark"); >> run("Threshold..."); >> waitForUser; >> setAutoThreshold("Default dark"); >> run("Threshold..."); >> waitForUser; >> setAutoThreshold("Huang dark"); >> run("Threshold..."); >> waitForUser; >> setAutoThreshold("Intermodes dark"); >> run("Threshold..."); >> waitForUser; >> setAutoThreshold("IsoData dark"); >> run("Threshold..."); >> Looking briefly within the code, I found the setMethod method within the >> ij.process.AutoThresholder which could be doing the job (through the >> "instance.methodChoice.select(method);" line). >> But the setAutoThreshold of the ij.macro.Functions class is calling the >> setAutoThreshold method of the ij.process.ImageProcessor class which will >> finally be calling the getThreshold method of the AutoThresholder class. >> And there is no call to a "instance.methodChoice.select(method);" >> instruction or equivalent. >> Looking forward for your lightings on this, please receive my best wishes >> for this new year! >> My best regards, >> Philippe >> >> Philippe CARL >> Laboratoire de Bioimagerie et Pathologies >> UMR 7021 CNRS - Université de Strasbourg >> Faculté de Pharmacie >> 74 route du Rhin >> 67401 ILLKIRCH >> Tel : +33(0)3 68 85 41 41 >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
