Hello,
I deal with many RAW images, each of varying dimensions and varying header sizes. Doing File->Import->Raw each time I wish to open a new image gets very tedious. What I would like to do is add a section of code to the HandleExtraFileTypes.java plugin. After the image fails to match any supported formats, my bit of code would then non-interactively attempt to open the file using the last used RAW import parameters. What I have now is as follows: //Try to open as RAW image ImportDialog impdlg = new ImportDialog(name,directory); FileInfo fi = impdlg.getFileInfo(); if (fi!=null) { FileOpener fo = new FileOpener(fi); imp = (ImagePlus)fo.open(false); if (imp!=null) return imp; } This allows me to drag and drop RAW images or use File->Import->Image Sequence, HOWEVER I have to accept the dialog settings for every single image. Is there a way to retrieve the settings used with the import RAW dialog box without actually displaying the dialog? Right now all the required variables or private members. I know I can retrieve the parameters from the prefs file, but that only contains the settings used from a previous session of ImageJ. I would like to be able to open one image successfully in ImageJ and then use those same settings from then on. Thanks for any suggestions! -Josh |
Use the ImportDialog.getLastFileInfo() method, which was added in
ImageJ 1.39t, to retrieve the settings used by the File>Import>Raw command. You can upgrade to v1.39t by using the ImageJ_Updater plugin (http://rsb.info.nih.gov/ij/plugins/imagej-updater.html) and selecting "daily build" from the drop down menu. The release notes for the daily build are at <http://rsbweb.nih.gov/ij/source/release-notes.html>. -wayne On Feb 27, 2008, at 2:05 PM, Josh D wrote: > Hello, > I deal with many RAW images, each of varying dimensions and varying > header sizes. Doing File->Import->Raw each time I wish to open a new > image gets very tedious. > > What I would like to do is add a section of code to the > HandleExtraFileTypes.java plugin. After the image fails to match any > supported formats, my bit of code would then non-interactively attempt > to open the file using the last used RAW import parameters. What I > have now is as follows: > > //Try to open as RAW image > ImportDialog impdlg = new ImportDialog(name,directory); > FileInfo fi = impdlg.getFileInfo(); > if (fi!=null) { > FileOpener fo = new FileOpener(fi); > imp = (ImagePlus)fo.open(false); > if (imp!=null) > return imp; > } > > This allows me to drag and drop RAW images or use File->Import->Image > Sequence, HOWEVER I have to accept the dialog settings for every > single image. > > > Is there a way to retrieve the settings used with the import RAW > dialog box without actually displaying the dialog? Right now all the > required variables or private members. I know I can retrieve the > parameters from the prefs file, but that only contains the settings > used from a previous session of ImageJ. I would like to be able to > open one image successfully in ImageJ and then use those same settings > from then on. > > Thanks for any suggestions! > -Josh > |
Excellent, close to perfect. However it appears that
ImportDialog.getLastFileInfo() only returns a non-null result if I actually click on File->Import->Raw. I'd like to be able to open ImageJ, drop a RAW file on the window, prompt me for the parameters, and from then on all images are opened without a dialog. I think the problem has to do with the fact that I'm using new ImportDialog, rather than using the existing instance of ImportDialog, so getLastFileInfo() isn't aware of my calls. Here is what I have so far. Any suggestions? Thanks! //Try to open as RAW image FileInfo fi=null; if(IJ.versionLessThan("1.39t")==false) fi = ImportDialog.getLastFileInfo(); if(fi==null) { ImportDialog impdlg = new ImportDialog(); fi = impdlg.getFileInfo(); } if (fi!=null) { fi.fileName=name; fi.directory=directory; FileOpener fo = new FileOpener(fi); imp = (ImagePlus)fo.open(false); if (imp!=null) return imp; } On 2/27/08, Wayne Rasband <[hidden email]> wrote: > Use the ImportDialog.getLastFileInfo() method, which was added in > ImageJ 1.39t, to retrieve the settings used by the File>Import>Raw > command. You can upgrade to v1.39t by using the ImageJ_Updater plugin > (http://rsb.info.nih.gov/ij/plugins/imagej-updater.html) and selecting > "daily build" from the drop down menu. The release notes for the daily > build are at <http://rsbweb.nih.gov/ij/source/release-notes.html>. > > > -wayne > > > On Feb 27, 2008, at 2:05 PM, Josh D wrote: > > > Hello, > > I deal with many RAW images, each of varying dimensions and varying > > header sizes. Doing File->Import->Raw each time I wish to open a new > > image gets very tedious. > > > > What I would like to do is add a section of code to the > > HandleExtraFileTypes.java plugin. After the image fails to match any > > supported formats, my bit of code would then non-interactively attempt > > to open the file using the last used RAW import parameters. What I > > have now is as follows: > > > > //Try to open as RAW image > > ImportDialog impdlg = new ImportDialog(name,directory); > > FileInfo fi = impdlg.getFileInfo(); > > if (fi!=null) { > > FileOpener fo = new FileOpener(fi); > > imp = (ImagePlus)fo.open(false); > > if (imp!=null) > > return imp; > > } > > > > This allows me to drag and drop RAW images or use File->Import->Image > > Sequence, HOWEVER I have to accept the dialog settings for every > > single image. > > > > > > Is there a way to retrieve the settings used with the import RAW > > dialog box without actually displaying the dialog? Right now all the > > required variables or private members. I know I can retrieve the > > parameters from the prefs file, but that only contains the settings > > used from a previous session of ImageJ. I would like to be able to > > open one image successfully in ImageJ and then use those same settings > > from then on. > > > > Thanks for any suggestions! > > -Josh > > > |
Free forum by Nabble | Edit this page |