Login  Register

Problems with variables in Math functions

Posted by Angus Jackson on Feb 13, 2009; 5:40pm
URL: http://imagej.273.s1.nabble.com/Problems-with-variables-in-Math-functions-tp3693715.html

Hi,

I am trying to do some operations on some images of micro-algae growing on rocky substrata. To do this I have been using the Process>Math>Multiply function but have been having trouble with the use of variables.

The values to be used in the image multiplication are held by different variables that are aquired automatically via other macros (e.g. measurements of mean pixel intensity inside a ROI).  
If I enter by hand the values then everything works ok.  If I try to use the variables (in this case the variable CalibIRFactor - see below) themselves in the multiply function then the image is altered, but not to the values expected.  I have checked the value of the variable (by printing) and it is correct.

So, my questions are:
Is it possible to use variable names in the Math functions?
What are the consequences of trying to do so?
If it is possible, where am I going wrong?
If it is not possible, then does anyone have any suggestions about how to extract the values of the variables and automatically enter them in to the Multiply function?

I am using version 1.42h

The code I have been trying to use is pasted below.

roiManager("Measure");
CalibIRMean = getResult("Mean",0); //In this particular case CalibIRMean equals 199
IRReflect = 20.400; //This is a constant
CalibIRFactor = IRReflect / CalibIRMean;  //Thus CalibIRFactor equals 0.1025
run("Select None");
run("Multiply...",CalibIRFactor);

If anyone has any thoughts or suggestions they would be very welcome.

Many thanks

Angus