Commit 3f20e360 authored by Cresson Remi's avatar Cresson Remi

ENH: add option to enable zero-y intercept

parent 08aa77b0
......@@ -296,9 +296,9 @@ private:
AddParameter(ParameterType_Int, "smoothingradius", "Smoothing radius (in pixels of the reference image)");
SetDefaultParameterInt ("smoothingradius", 10);
AddParameter(ParameterType_Choice, "useoffset", "Zero-y intercept mode in linear transform");
AddChoice("useoffset.on", "Yes (y=ax+b)");
AddChoice("useoffset.off", "No (y=ax)");
AddParameter(ParameterType_Choice, "zeroy", "Zero-y intercept mode in linear transform");
AddChoice("zeroy.on", "Yes (y=ax)");
AddChoice("zeroy.off", "No (y=ax+b)");
AddRAMParameter();
......@@ -411,7 +411,8 @@ private:
std::stringstream exp;
exp << "{";
if (GetParameterInt("useoffset") == 0)
bool zeroy = (GetParameterInt("zeroy") == 0);
if (zeroy)
{
otbAppLogINFO("Using zero-y intercept (y=ax)");
}
......@@ -428,15 +429,15 @@ private:
float mean2X = meanX * meanX;
float b0, b1;
if (GetParameterInt("useoffset") == 1)
if (zeroy)
{
b1 = (meanX * meanY - meanXY) / (mean2X - meanX2);
b0 = meanY - b1 * meanX;
b1 = meanXY / meanX2;
b0 = 0;
}
else
{
b1 = meanXY / meanX2;
b0 = 0;
b1 = (meanX * meanY - meanXY) / (mean2X - meanX2);
b0 = meanY - b1 * meanX;
}
otbAppLogINFO("Band " << band << " gain: " << b1 << " bias: " << b0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment