Hi. I am runnin imagej batches and i am using the set threshold auto
feature for some of my images. How do i find out what value imagej autoset the threshold to? Is there a getThreshold function or amything of the sorts? Thanks -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Adam,
On Tue, 11 Sep 2012, Adam Hughes wrote: > I am runnin imagej batches and i am using the set threshold auto feature > for some of my images. How do i find out what value imagej autoset the > threshold to? Is there a getThreshold function or amything of the sorts? You guessed right: http://imagej.nih.gov/ij/developer/macro/functions.html#getThreshold Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Adam,
it is a good practice in the ImageJ/Fiji community to let other people learn from other scientists' discussions, so I re-Cc:ed the list. I hope you do not mind! On Wed, 12 Sep 2012, Adam Hughes wrote: > Because I"m so unfamiliar to java, how would I get imagej to write this > value to a file? Say my getThreshold() would return some numbers.... > the following doesn't work: > > d=File.open('myfile') > print(d, getTHreshold()) > > says number or numeric function expected I think that you meant macro programming, right? It is similar, but not quite identical to Java. One thing that is identical to Java is that you need to end your statement with a semicolon. So it would be: d=File.open('myfile'); instead of d=File.open('myfile') and likewise for the print() statement. Another thing Java and the macro language have in common is that they are case-sensitive. So it makes a difference whether you write getTHreshold() or getThreshold(). The latter will work, the former not. Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks Johannes. I made the corrections you suggested but am still getting
the error. Maybe I should clarify a bit of what I'm trying to do. In ImageJ, if I open the image adjust threshold panel, and just hit auto--->apply without doing any manual thresholding, this is what the imagej macro recorder outputs: setAutoThreshold("Default dark"); //run("Threshold..."); setAutoThreshold("Default dark"); *setThreshold(117, 255);* run("Convert to Mask"); ImageJ thus decided upon the values 117,255 for the optimal threshold. What I'm trying to do is output these two values when batch processing. Is my approach of: d=File.open("myfile.txt"); print(d, getThreshold() ); The right idea? This is still giving me an error :Number or numeric function expected... " and it shows the second line above. Thanks for your help Johannes, you've cleared a lot up for me so far. On Wed, Sep 12, 2012 at 7:25 PM, Johannes Schindelin < [hidden email]> wrote: > Hi Adam, > > it is a good practice in the ImageJ/Fiji community to let other people > learn from other scientists' discussions, so I re-Cc:ed the list. I hope > you do not mind! > > On Wed, 12 Sep 2012, Adam Hughes wrote: > > > Because I"m so unfamiliar to java, how would I get imagej to write this > > value to a file? Say my getThreshold() would return some numbers.... > > the following doesn't work: > > > > d=File.open('myfile') > > print(d, getTHreshold()) > > > > says number or numeric function expected > > I think that you meant macro programming, right? It is similar, but not > quite identical to Java. > > One thing that is identical to Java is that you need to end your statement > with a semicolon. So it would be: > > d=File.open('myfile'); > > instead of > > d=File.open('myfile') > > and likewise for the print() statement. > > Another thing Java and the macro language have in common is that they are > case-sensitive. So it makes a difference whether you write getTHreshold() > or getThreshold(). The latter will work, the former not. > > Ciao, > Johannes > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Adam,
On Wed, 12 Sep 2012, Adam Hughes wrote: > print(d, getThreshold() ); > > This is still giving me an error :Number or numeric function expected..." I think the problem is that getThreshold() actually takes two variable names by reference and sets their values to the lower/upper threshold respectively. This is most likely to the limitation that the macro language's syntax does not allow more than one return value (and indeed it should not allow that, lest it deviates from the well-known Java syntax even further). So the correct way to do it in your case is probably something like getThreshold(threshold, max); print(d, threshold); Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks Johannes, this works splendidly!
I did not really understand the passing variable by reference idea and was trying to use a call signature similar to Python. Thanks a great deal. On Thu, Sep 13, 2012 at 1:58 AM, Johannes Schindelin < [hidden email]> wrote: > Hi Adam, > > On Wed, 12 Sep 2012, Adam Hughes wrote: > > > print(d, getThreshold() ); > > > > This is still giving me an error :Number or numeric function expected..." > > I think the problem is that getThreshold() actually takes two variable > names by reference and sets their values to the lower/upper threshold > respectively. This is most likely to the limitation that the macro > language's syntax does not allow more than one return value (and indeed it > should not allow that, lest it deviates from the well-known Java syntax > even further). > > So the correct way to do it in your case is probably something like > > getThreshold(threshold, max); > print(d, threshold); > > Ciao, > Johannes > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |