Hi everyone,
though I consider myself a seasoned ImageJ user, a beginner's question (sorry if I have overlooked something trivial) Is there a way to have a comment or some other text that I can edit, have it stored with the image (in the .tif or .zip file), retrieve it later? (and maybe edit it, store the image again...) Of course, I could write a plugin for this, adding a String to the image metadata, but I don't want to reinvent the wheel. (The TIFF 'description' tag seems to be in use already, storing calibration, min&max) Michael ________________________________________________________________ |
2010/12/20 Michael Schmid <[hidden email]>:
> Hi everyone, > > though I consider myself a seasoned ImageJ user, a beginner's question > (sorry if I have overlooked something trivial) > > Is there a way to have a comment or some other text that I can edit, have it > stored with the image (in the .tif or .zip file), retrieve it later? (and > maybe edit it, store the image again...) > > Of course, I could write a plugin for this, adding a String to the image > metadata, but I don't want to reinvent the wheel. > (The TIFF 'description' tag seems to be in use already, storing calibration, > min&max) Michael, There's the ImagePlus properties, to which one may add more. They are saved in the TIFF file header. Albert -- http://albert.rierol.net |
In reply to this post by Michael Schmid
On Dec 20, 2010, at 10:30 AM, Michael Schmid wrote:
> Hi everyone, > > though I consider myself a seasoned ImageJ user, a beginner's > question (sorry if I have overlooked something trivial) > > Is there a way to have a comment or some other text that I can edit, > have it stored with the image (in the .tif or .zip file), retrieve it > later? (and maybe edit it, store the image again...) > > Of course, I could write a plugin for this, adding a String to the > image metadata, but I don't want to reinvent the wheel. > (The TIFF 'description' tag seems to be in use already, storing > calibration, min&max) You can add text to an image using the the Edit>Copy to Image Info command in the text editor. You can retrieve the text, which is saved in the TIFF header, by pressing the "i" key (Image>Show Info). Macros can add text to an image by calling setMetadata("Info", string) and retrieve it using getMetadata("Info"). Plugins can add text to an image using imp.setProperty("Info", String) and retrieve it using text=(String)imp.getProperty("Info"). -wayne |
In spite of Wayne's explanation I cannot get the following 3 macros to do this:
1. create an image with metadata "old text" 2. put "old text" into a text window so I can change it to "new text" 3. put "new text" back to the metadata. The problem is that after the second macro, all menus disappear (OS X), and the window is not editable either. N. Vischer ---------- macro "Create Demo image [F1]"{ newImage("A", "8-bit Ramp", 280, 250, 1); setMetadata("Info", "old text"); } macro"Show Info [F2]"{ info = getMetadata("Info"); title1 = "Description"; title2 = "["+title1+"]"; f = title2; if (isOpen(title1)){ selectWindow(title1); print(f, "\\Update:"); // clears the window } else run("Text Window...", "name="+title2); print(f, info); } macro "Store Info[F3]"{ str = getInfo("window.contents"); setMetadata("info", str); } |
Hi Norbert, Wayne,
indeed, I can confirm that on Mac OS X 10.4.11 (Jave 1.5.0_19), there is an almost empty menu bar (only the Apple and the "ImageJ" column) for a text window if Plugins>Menu>New Text Window... has the "Menu Bar" option off (I guess that it should rather have the standard ImageJ menu bar?) So, in the macro it should be run("Text Window...", "name="+title2+" menu"); Best wishes, Michael ________________________________________________________________ On 15 Feb 2011, at 02:01, Norbert Vischer wrote: > In spite of Wayne's explanation I cannot get the following 3 macros > to do this: > > 1. create an image with metadata "old text" > 2. put "old text" into a text window so I can change it to "new text" > 3. put "new text" back to the metadata. > > The problem is that after the second macro, all menus disappear (OS > X), > and the window is not editable either. > > N. Vischer > ---------- > > > macro "Create Demo image [F1]"{ > newImage("A", "8-bit Ramp", 280, 250, 1); > setMetadata("Info", "old text"); > } > > macro"Show Info [F2]"{ > info = getMetadata("Info"); > title1 = "Description"; > title2 = "["+title1+"]"; > f = title2; > if (isOpen(title1)){ > selectWindow(title1); > print(f, "\\Update:"); // clears the window > } > else > run("Text Window...", "name="+title2); > print(f, info); > } > > macro "Store Info[F3]"{ > str = getInfo("window.contents"); > setMetadata("info", str); > } |
In reply to this post by Michael Schmid
Norbert,
This seems to work here (Mac OS 10.6.5; Java 1.6, ImageJ 1.45b4), : macro "Create Demo image [F1]"{ newImage("A", "8-bit Ramp", 280, 250, 1); setMetadata("Info", "old text"); } macro"Show Info [F2]"{ info = getMetadata("Info"); title1 = "Description"; title2 = "["+title1+"]"; f = title2; if (isOpen(title1)){ selectWindow(title1); print(f, "\\Update:"); // clears the window } else run("Text Window...", "name="+title2+" menu"); print(f, "new text"); } macro "Store Info[F3]"{ selectWindow("Description"); str = getInfo("window.contents"); selectWindow("A"); setMetadata("info", str); } The window focus of "Store Info" has been explicitly set to "Description". Otherwise, the window.contents of the window "Macro" (which I had created to hold and run your test macros) was itself copied into the metadata. Bill Christens-Barry |
Thanks Wayne, Michael and Bill for the answers.
In the meantime I have chosen to solve my problem with a modal dialog, so the solutions discussed here may be used in future when longer text is involved. Obviously it is not easy to have simultaneous write access to a text window for both macro and user. Bill, if I try your modified macros in a back-and-forth manner (F1 - F2 - F3 - F2), the text window "Description" is neither updated, nor is it editable anymore It would be much simpler if the Log window was editable (similar to the Macro Recorder window). Norbert Vischer > > This seems to work here (Mac OS 10.6.5; Java 1.6, ImageJ 1.45b4), : > > macro "Create Demo image [F1]"{ > newImage("A", "8-bit Ramp", 280, 250, 1); > setMetadata("Info", "old text"); > } > > macro"Show Info [F2]"{ > info = getMetadata("Info"); > title1 = "Description"; > title2 = "["+title1+"]"; > f = title2; > if (isOpen(title1)){ > selectWindow(title1); > print(f, "\\Update:"); // clears the window > } > else > run("Text Window...", "name="+title2+" menu"); > print(f, "new text"); > } > > macro "Store Info[F3]"{ > selectWindow("Description"); > str = getInfo("window.contents"); > selectWindow("A"); > setMetadata("info", str); > } > > The window focus of "Store Info" has been explicitly set to "Description". Otherwise, the window.contents of the window "Macro" (which I had created to hold and run your test macros) was itself copied into the metadata. > > Bill Christens-Barry |
Free forum by Nabble | Edit this page |