Macro/plugin for image calculations: is this possible?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro/plugin for image calculations: is this possible?

J PIke
I have been normalizing images and creating composite images successfully using imageJ and have written some simple macros to speed up the processing of the large quantities of images I am analysing. I now want to speed things up further, the problem which I'm not sure is surmountable is that the output from one calculation or measurement is the input for the next calculation.

Briefly, these are pairs of images of the same target captured at different wavelengths (a,b), the images are normalized to a calibration panel which is in the image field, a mathematical function is then applied to the 2 images to create a composite image:

A = (a x 18) / calibration panel value for a
B = (b x 18) / calibration panel value for b

Final composite image = (A – B)/(A + B)

Does somebody know whether it is feasible to write a plugin which when fed two raw images will output the desired composite image? If so any pointers?

Thanks

P.S. If you’re curious this is to calculate an index of photosynthetic biomass, the final image is the normalized difference vegetation index (NDVI) and the two wavelengths are near infrared and red.
Reply | Threaded
Open this post in threaded view
|

Re: Macro/plugin for image calculations: is this possible?

Harry Parker
Hello J,

What you want to do is quite easy using a macro. Writing a plugin won't be necessary.

The Macro Recorder is your friend. Read up on how to use it. (Just run it and do what you do to manually calculate your images. Then edit the resulting file to make it more general and allow the  operator to select the files to use.)

If you haven't already, read up the pages of the ImageJ macro language and scan the macro functions page. Scan the list of prewritten macros for valuable examples.

Give it a try and let us know if you get stuck.
 

--  
Harry Parker  
Senior Systems Engineer  
Digital Imaging Systems, Inc.

----- Original Message ----
From: J PIke <[hidden email]>
To: [hidden email]
Sent: Friday, May 11, 2007 1:30:14 PM
Subject: Macro/plugin for image calculations: is this possible?

I have been normalizing images and creating composite images successfully
using imageJ and have written some simple macros to speed up the processing
of the large quantities of images I am analysing. I now want to speed things
up further, the problem which I'm not sure is surmountable is that the
output from one calculation or measurement is the input for the next
calculation.

Briefly, these are pairs of images of the same target captured at different
wavelengths (a,b), the images are normalized to a calibration panel which is
in the image field, a mathematical function is then applied to the 2 images
to create a composite image:

A = (a x 18) / calibration panel value for a
B = (b x 18) / calibration panel value for b

Final composite image = (A – B)/(A + B)

Does somebody know whether it is feasible to write a plugin which when fed
two raw images will output the desired composite image? If so any pointers?

Thanks

P.S. If you’re curious this is to calculate an index of photosynthetic
biomass, the final image is the normalized difference vegetation index
(NDVI) and the two wavelengths are near infrared and red.

--
View this message in context: http://www.nabble.com/Macro-plugin-for-image-calculations%3A-is-this-possible--tf3728638.html#a10436253
Sent from the ImageJ mailing list archive at Nabble.com.





       
____________________________________________________________________________________Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222
Reply | Threaded
Open this post in threaded view
|

Re: Macro/plugin for image calculations: is this possible?

J PIke
As you say it is does seem quiet managable. However, I've written a macro which I'm having a problem getting to work (below). If I put in a value instead of a getResult command it works fine e.g.

Replace:

NIRcal = getResult("Mean",nResults-1);

with:

NIRcal = "value=70.000";

I find this strange as if I display NIRcal e.g. print(NIRcal) it shows the value that I want it to use. It just refuses to use this value in the divide operation.....

 
        x = 1400
        y = 900
        w = 200
        h = 200
        CarRef = "value=18.000"
        run("16-bit");
        makeRectangle(x, y, w, h);
        run("Set Measurements...", "  mean standard min redirect=None decimal=3");
        run("Measure");
        IH = getHeight();
        IW = getWidth();
        makeRectangle(0, 0, IW, IH);
        run("Multiply...", CarRef);
        NIRcal = getResult("Mean",nResults-1);
        run("Divide...", NIRcal);
        makeRectangle(x, y, w, h);
        run("Measure");

Cheers

James

       

Harry Parker wrote
Hello J,

What you want to do is quite easy using a macro. Writing a plugin won't be necessary.

The Macro Recorder is your friend. Read up on how to use it. (Just run it and do what you do to manually calculate your images. Then edit the resulting file to make it more general and allow the  operator to select the files to use.)

If you haven't already, read up the pages of the ImageJ macro language and scan the macro functions page. Scan the list of prewritten macros for valuable examples.

Give it a try and let us know if you get stuck.
 

--  
Harry Parker  
Senior Systems Engineer  
Digital Imaging Systems, Inc.

----- Original Message ----
From: J PIke <james.pike@PLYMOUTH.AC.UK>
To: IMAGEJ@LIST.NIH.GOV
Sent: Friday, May 11, 2007 1:30:14 PM
Subject: Macro/plugin for image calculations: is this possible?

I have been normalizing images and creating composite images successfully
using imageJ and have written some simple macros to speed up the processing
of the large quantities of images I am analysing. I now want to speed things
up further, the problem which I'm not sure is surmountable is that the
output from one calculation or measurement is the input for the next
calculation.

Briefly, these are pairs of images of the same target captured at different
wavelengths (a,b), the images are normalized to a calibration panel which is
in the image field, a mathematical function is then applied to the 2 images
to create a composite image:

A = (a x 18) / calibration panel value for a
B = (b x 18) / calibration panel value for b

Final composite image = (A – B)/(A + B)

Does somebody know whether it is feasible to write a plugin which when fed
two raw images will output the desired composite image? If so any pointers?

Thanks

P.S. If you’re curious this is to calculate an index of photosynthetic
biomass, the final image is the normalized difference vegetation index
(NDVI) and the two wavelengths are near infrared and red.

--
View this message in context: http://www.nabble.com/Macro-plugin-for-image-calculations%3A-is-this-possible--tf3728638.html#a10436253
Sent from the ImageJ mailing list archive at Nabble.com.





       
____________________________________________________________________________________Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222
Reply | Threaded
Open this post in threaded view
|

Re: Macro/plugin for image calculations: is this possible?

Michael Schmid
On 16 May 2007, at 17:43, J PIke wrote:

> If I put in a value
> instead of a getResult command it works fine e.g.
>
> Replace:
>
> NIRcal = getResult("Mean",nResults-1);
>
> with:
>
> NIRcal = "value=70.000";
>
> I find this strange as if I display NIRcal e.g. print(NIRcal) it  
> shows the
> value that I want it to use. It just refuses to use this value in  
> the divide
> operation.....
>
> (...)
> NIRcal = getResult("Mean",nResults-1);
> run("Divide...", NIRcal);

you need the string NIRcal = "value=70.000" as argument to run
("Divide..."
So it should be NIRcal =  "value=" + getResult("Mean",nResults-1);

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Macro/plugin for image calculations: is this possible?

CaptainToenail
In reply to this post by J PIke
Hi
I am doing a similar project to yours but instead of using NDVI as an index of photosynthetic biomass I intend to use it to detect drought stress in vegetation that has been photographed over three years being subjected to different levels of water stress.

I am very new to imageJ so I was wondering if you had any advice?

The images were captured by two cameras mounted on a structure above the plots. One camera having a visible light filter so that it captures only infrared light, and the other capturing visible light. I have registered and georeferenced etc, the images on ENVI but haven't been able to get much further. The NDVI values I have calculated have all been negative...

Cheers