Hi,
I'm really new to ImageJ and macros in general. My goal is to have research assistants be able to open the first image in a folder manually, measure RGB for three set locations that they have to select with a rectangle, then have it automatically save the results and possibly close the file and open the next image in the folder. Right now I have the first part: setTool("rectangle"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); I'm just not sure how to save the results window. Any help you can give would be greatly appreciated. |
Hi Hydranassa,
to save the results in a macro, first select the Results Window selectWindow("Results"); Then use saveAs("txt", pathAndFileName); Here, pathAndFileName is where you want to save it. If you want to save it in the same directory as the image, you can have, e.g. pathAndFileName = getInfo("image.directory")+getTitle()+"_RGBvalues.txt"; See http://rsb.info.nih.gov/ij/developer/macro/functions.html#selectWindow http://rsb.info.nih.gov/ij/developer/macro/functions.html#saveAs Michael ________________________________________________________________ On Nov 14, 2012, at 01:42, hydranassa wrote: > Hi, > I'm really new to ImageJ and macros in general. My goal is to have research > assistants be able to open the first image in a folder manually, measure RGB > for three set locations that they have to select with a rectangle, then have > it automatically save the results and possibly close the file and open the > next image in the folder. > Right now I have the first part: > > setTool("rectangle"); > run("Select None"); > waitForUser("Select areas","Select the area to analyze and click 'OK'"); > getSelectionBounds(x,y,width,height); > run("Measure RGB"); > run("Select None"); > waitForUser("Select areas","Select the area to analyze and click 'OK'"); > getSelectionBounds(x,y,width,height); > run("Measure RGB"); > run("Select None"); > waitForUser("Select areas","Select the area to analyze and click 'OK'"); > getSelectionBounds(x,y,width,height); > run("Measure RGB"); > > I'm just not sure how to save the results window. > Any help you can give would be greatly appreciated. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by hydranassa
Dear Hydranassa,
What do you try to do? Make a selection of 3 ROIs in the first image in a directory and analyse all other images using these selections or do you want the user to draw 3 ROIs on each image in the directory? Kees -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of hydranassa Sent: 14 November 2012 00:43 To: [hidden email] Subject: User-defined tasks then save results Hi, I'm really new to ImageJ and macros in general. My goal is to have research assistants be able to open the first image in a folder manually, measure RGB for three set locations that they have to select with a rectangle, then have it automatically save the results and possibly close the file and open the next image in the folder. Right now I have the first part: setTool("rectangle"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); run("Select None"); waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); I'm just not sure how to save the results window. Any help you can give would be greatly appreciated. -- View this message in context: http://imagej.1557.n6.nabble.com/User-defined-tasks-then-save-results-tp5000795.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kees,
I want the user to draw 3 ROIs on each image. I am analyzing animal patterns and the animals aren't always in the exact same spot in the photograph. Thanks, Hydranassa |
Hi Hydranassa,
The macro below might do what you have in mind. It will ask the user for the directory with images and will open each image indvidually. Results per image are stored in a subdirectory "results". At the momentthe function getSelectionBounds(x,y,width,height); is not used for anything. dir1 = getDirectory("Choose file directory "); File.makeDirectory(dir1+File.separator+"results"); dir2 = dir1+"results"; setTool("rectangle"); list = getFileList(dir1); for (i=0; i<list.length; i++) { if (File.isDirectory(dir1+list[i])){} else{ path = dir1+list[i]; open(path); title1=getTitle; title2=File.nameWithoutExtension; for (j=1;j<4;j++){ waitForUser("Select areas","Select the area to analyze and click 'OK'"); getSelectionBounds(x,y,width,height); run("Measure RGB"); run("Select None"); } selectWindow(title1); close(); selectWindow("Results"); saveAs("txt", dir2+File.separator+"Results"+title2); run("Close"); } } Best wishes Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of hydranassa [[hidden email]] Sent: 14 November 2012 18:02 To: [hidden email] Subject: Re: User-defined tasks then save results Hi Kees, I want the user to draw 3 ROIs on each image. I am analyzing animal patterns and the animals aren't always in the exact same spot in the photograph. Thanks, Hydranassa -- View this message in context: http://imagej.1557.n6.nabble.com/User-defined-tasks-then-save-results-tp5000795p5000812.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |