Whenever I run the following code I get an error that no windows are open. I know that i could rewrite as: IJ.open("path"+(i)+".jpg"); however i am trying t save the runtime from opening the windows for 900 images.
Thanks, Kyle for(int i=0; i<900; i++){ ImagePlus image1 =IJ.openImage("path"+(i)+".jpg"); ij.setThreshold(threshold, 255,"Black & White"); } |
On Feb 2, 2017, at 12:33 PM, kt7 <[hidden email]> wrote:
> > Whenever I run the following code I get an error that no windows are open. I > know that i could rewrite as: IJ.open("path"+(i)+".jpg"); however i am > trying t save the runtime from opening the windows for 900 images. > Thanks, > Kyle > > for(int i=0; i<900; i++){ > ImagePlus image1 =IJ.openImage("path"+(i)+".jpg"); > ij.setThreshold(threshold, 255,"Black & White"); > } Use IJ.setThreshold(image1, threshold, 255,"Black & White"); -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank You so much works great.
Another quick question though, as I am analyzing particles I can't seem to get the area of any of them to return as an integer: IJ.run(imageOutput, "Analyze Particles...", "size="+minCellSize+"-"+maxCellSize+" exclude include"); I'm not sure the next command to run in order to work with an individual particle. I was thinking I could add to the ROI manager but again I don't know how to get the area of individual particles. Thank you, Kyle |
> On Feb 3, 2017, at 11:46 AM, kt7 <[hidden email]> wrote:
> > Thank You so much works great. > Another quick question though, as I am analyzing particles I can't seem to > get the area of any of them to return as an integer: > > IJ.run(imageOutput, "Analyze Particles...", > "size="+minCellSize+"-"+maxCellSize+" exclude include"); > > I'm not sure the next command to run in order to work with an individual > particle. I was thinking I could add to the ROI manager but again I don't > know how to get the area of individual particles. > Thank you, The particle analyzer saves results to the system ResultsTable. The following JavaScript example runs the particle analyzer, retrieves the system ResultsTable, and then displays the area and mean of the individual particles. -wayne imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif"); IJ.setAutoThreshold(imp, "Default"); IJ.run("Set Measurements...", "area mean"); min=100; max=400; IJ.run(imp, "Analyze Particles...", "size="+min+"-"+max+" clear"); rt = Analyzer.getResultsTable(); for (i=0; i<rt.size(); i++) print(i+": area="+rt.getValue("Area",i)+", mean="+rt.getValue("Mean",i)); -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
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 |
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 |
Free forum by Nabble | Edit this page |