Login  Register

Re: How to assign a double (or other variable) to an image

Posted by Wayne Rasband on Jan 29, 2008; 10:43pm
URL: http://imagej.273.s1.nabble.com/How-to-assign-a-double-or-other-variable-to-an-image-tp3697381p3697383.html

You can save the value as the "Info" image property. Use

     imp.setProperty("Info", ""+value);

to save the value and this method

    double getValue(ImagePlus imp) {
       Object info = imp.getProperty("Info");
       if (info!=null && info instanceof String)
          return Tools.parseDouble((String)info, Double.NaN);
       else
          return Double.NaN;
       }

to retrieve it. In a macro use

     setMetadata(value);

to save the value and

     value = getMetadata();

to retrieve it.

-wayne


On Jan 29, 2008, at 4:50 PM, Dwight U. Bartholomew wrote:

> I would like to assign one or more values to an image. How do I do
> that?
>
> I'm writing a PlugIn to perform noise analysis on infrared images.  At
> some point, the algorithm asks the User to input a "signal transfer
> function" (SiTF) that maps image units to degrees-Centigrade.
>
> After running my analysis, I'd like to be able to assign the SiTF value
> to the image.  Why?  So that if I run the analysis again (on, say, a
> different ROI) I don't have to type the darned number in again.  I can
> just read it off the image.
>
> Visual Basic used to have "tags" for any object; they were strings that
> could be used for anything.  I'm wondering if there is something
> similar
> associated with an Image within ImageJ that I can use to store my SiTF
> value.
>
> Any ideas?
>
> Dwight Bartholomew
>