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 |
Hi Angus,
Use the macro recorder to see what it looks like with fixed values and then concatenate strings to get the same with variables. In your case: Fixed values (from macro recorder): run("Multiply...", "value=1.250"); Thus with variables: run("Multiply...", "value="+CalibIRFactor); Michael ________________________________________________________________ On 13 Feb 2009, at 18:40, Angus Jackson wrote: > 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 > -- > View this message in context: http://n2.nabble.com/Problems-with- > variables-in-Math-functions-tp2322588p2322588.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |