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: ...@@ -296,9 +296,9 @@ private:
AddParameter(ParameterType_Int, "smoothingradius", "Smoothing radius (in pixels of the reference image)"); AddParameter(ParameterType_Int, "smoothingradius", "Smoothing radius (in pixels of the reference image)");
SetDefaultParameterInt ("smoothingradius", 10); SetDefaultParameterInt ("smoothingradius", 10);
AddParameter(ParameterType_Choice, "useoffset", "Zero-y intercept mode in linear transform"); AddParameter(ParameterType_Choice, "zeroy", "Zero-y intercept mode in linear transform");
AddChoice("useoffset.on", "Yes (y=ax+b)"); AddChoice("zeroy.on", "Yes (y=ax)");
AddChoice("useoffset.off", "No (y=ax)"); AddChoice("zeroy.off", "No (y=ax+b)");
AddRAMParameter(); AddRAMParameter();
...@@ -411,7 +411,8 @@ private: ...@@ -411,7 +411,8 @@ private:
std::stringstream exp; std::stringstream exp;
exp << "{"; exp << "{";
if (GetParameterInt("useoffset") == 0) bool zeroy = (GetParameterInt("zeroy") == 0);
if (zeroy)
{ {
otbAppLogINFO("Using zero-y intercept (y=ax)"); otbAppLogINFO("Using zero-y intercept (y=ax)");
} }
...@@ -428,15 +429,15 @@ private: ...@@ -428,15 +429,15 @@ private:
float mean2X = meanX * meanX; float mean2X = meanX * meanX;
float b0, b1; float b0, b1;
if (GetParameterInt("useoffset") == 1) if (zeroy)
{ {
b1 = (meanX * meanY - meanXY) / (mean2X - meanX2); b1 = meanXY / meanX2;
b0 = meanY - b1 * meanX; b0 = 0;
} }
else else
{ {
b1 = meanXY / meanX2; b1 = (meanX * meanY - meanXY) / (mean2X - meanX2);
b0 = 0; b0 = meanY - b1 * meanX;
} }
otbAppLogINFO("Band " << band << " gain: " << b1 << " bias: " << b0); 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