【问题标题】:Getting the equation out of a fitted curve in ImageJ从 ImageJ 中的拟合曲线中获取方程
【发布时间】:2014-02-21 08:17:43
【问题描述】:

我正在一个名为 ImageJ 的免费软件中分析 gafchromic 滤镜,该软件使用 Java 的简化形式来编写宏。

我有一组数据点,我已经成功地用不同的方法连接起来,并确定三次多项式最适合数据,但是我需要使用实际曲线,所以我需要以某种方式提取方程/公式多项式。这应该是可能的,因为定义多项式的变量列在生成的图表上,但是我似乎找不到在代码中提取它们的方法。

到目前为止,这是我的代码:

n = nResults();
x = newArray(n);
for (i=0; i<x.length; i++)
{
    x[i] = getResult("Grays ", i);
}

y = newArray(n);
for (i=0; i<y.length; i++)
{
    y[i] = getResult("Mean ", i);

}


// Do all possible fits, plot them and add the plots to a stack
setBatchMode(true);
for (i = 0; i < Fit.nEquations; i++) {
 Fit.doFit(i, x, y);
 Fit.plot();
 if (i == 0)
     stack = getImageID;
 else {
     run("Copy");
     close();
     selectImage(stack);
     run("Add Slice");
     run("Paste");
 }
 Fit.getEquation(i, name, formula);
 print(""); print(name+ " ["+formula+"]");
 print("   R^2="+d2s(Fit.rSquared,3));
 for (j=0; j<Fit.nParams; j++)
     print("   p["+j+"]="+d2s(Fit.p(j),6));
 }
 setBatchMode(false);
 run("Select None");
 rename("Curve Fits");

}

【问题讨论】:

标签: macros extract equation curve-fitting imagej


【解决方案1】:

如上所述,我已经在其他地方得到了答案。尽管如此,我也想把它留在这里作为记录。 基本上,答案已经包含在原始帖子中,因为它将各个变量打印到“日志”窗口中。

对于三次多项式,我可以使用:

Fit.doFit(2, x, y); // 2 is 3rd Degree Polynomial
Fit.plot();
rename("Calibrating curve");

然后可以很容易地提取出来:

a = Fit.p(0);
b = Fit.p(1);
c = Fit.p(2);
d = Fit.p(3);

【讨论】:

    猜你喜欢
    • 2015-03-02
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 2021-08-03
    • 1970-01-01
    • 2017-08-04
    • 2014-06-21
    • 1970-01-01
    相关资源
    最近更新 更多