Login  Register

Re: Saving with no open windows

Posted by Michael Schmid on Feb 06, 2017; 2:43pm
URL: http://imagej.273.s1.nabble.com/Plugin-to-adjust-threshold-without-opening-window-tp5018002p5018033.html

Hi Kyle,

please make sure you have the correct number and sequence of arguments
for IJ.saveAs:
   IJ.saveAs(image1, "png","/path/to/temp.png");

With Javascript, the following works for me:
   image1 = IJ.openImage("/Users/schmid/Desktop/temp.png");
   IJ.setThreshold(image1, 0, 128, "Black & White");
   Prefs.blackBackground = true;
   IJ.run(image1, "Convert to Mask", "");
   IJ.saveAs(image1, "png", "/Users/schmid/Desktop/temp1.png");

Michael
________________________________________________________________


On 2017-02-05 23:32, kt7 wrote:

> I'm working on developing a java plugin where I am converting images to
> binary without opening them by using:
>
> ImagePlus image1 = IJ.openImage("/Path/to/file");
> IJ.setThreshold(image1, thresholdLower, thresholdUpper, "Black &
> White");
> Prefs.blackBackground = true;
> IJ.run(image1, "Convert to Mask", "");
> IJ.save(image1, "/Path/to/output");
>
> I have tried IJ.saveAs and both give me the error that there are no
> open
> windows. How do I save these changes that I have made without needing
> the
> window to be open?
>
> Thanks,
> Kyle
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html