#include <Base/Image/Image.hh>
#include <Base/ImageUtils/ImageDraw.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Geometry/HomgPoint2D.hh>
#include <Base/Debug/TimeMeasure.hh>
#include <Image/TextureTransformHomography.hh>
#include <Image/TextureTransformSimilar.hh>
#include <Image/TextureTransformAffine.hh>
#include <Image/TextureTransformDisplacement.hh>
#include <Image/TextureTransformDisparity.hh>
#include <Base/Math/Random.hh>
#include <Matcher2D/ImageAlignment.hh>
#include <Image/TextureMapping.hh>
#include <iostream>
#include <iomanip>
using namespace BIAS;
using namespace std;
{
BIASERR("error loading image "<<name);
return -1;
}
BIASERR("error converting image "<<name);
return -2;
}
BIASERR("error converting image to grey "<<name);
return -3;
}
}
return 0;
}
int main(int argc, char*argv[])
{
if (argc<2) {
cerr << argv[0] << " <image> "<< endl;
return -1;
}
if (LoadImage(argv[1], im[0]) != 0) {
BIASERR("error loading image " << argv[1]);
return -1;
}
im[1] = im[0];
p[0][2] = p[1][2] = 1.0;
int mode = 3;
switch (mode) {
cout<<"Testing HOMOGRAPHY"<<endl;
par.
newsize(6); par[0] = 0.1; par[1] = 0.1; par[2] = 0.1; par[3] = 0.1;
par[4] = 1; par[5] = -1; par[6] = 0.01; par[7] = -0.01;
break;
cout<<"Testing AFFINITY"<<endl;
par.
newsize(6); par[0] = 0.2; par[1] = -0.1; par[2] = -0.2; par[3] = 0.3;
par[4] = 1; par[5] = -1;
par[0] = cos(0.4)-1.0; par[1] = sin(0.4); par[2] = -sin(0.4); par[3] = cos(0.4)-1.0;
par[4] = -2; par[5] = 2;
break;
cout<<"Testing SIMILARITY"<<endl;
par.
newsize(4); par[0] = -0.3; par[1] = 0.3; par[2] = 1; par[3] = -1;
break;
cout<<"Testing DISPLACEMENT"<<endl;
par.
newsize(2); par[0] = -1; par[1] = 1;
break;
cout<<"Testing DISPARITY"<<endl;
}
cout<<"using parameters "<<par<<endl;
origpar = par;
if (pTTS!=NULL) {
cout<<"setting origin !"<<thepoint2<<endl;
}
if (pTTA!=NULL) {
cout<<"setting origin !"<<thepoint2<<endl;
}
im[1] = im[0];
bool brightnesschange = true;
if (false) {
do {
*pData = 0.9f * *pData + 20.0f;
} while (pData++ < pDataEnd);
}
double pixelnoise = 0.0;
if (pixelnoise>0.0) {
do {
} while (pData++ < pDataEnd);
}
cov *= 1e-10;
double parameternoise = 0.2;
if (parameternoise>0.0) {
for (
int i=par.
Size()-1; i>=0; i--) {
cov[i][i] = par[i]*par[i]*parameternoise*parameternoise + 1e-10;
}
}
cout<<"Setting alignment pixels"<<endl<<flush;
cout<<"Aligning ..."<<endl<<flush;
int result =
double scale=0, offset=0;
cout << "result: " << result << ", "
<< p[0] << " -> " << par << ", "<<endl;
cout<<"original parameters were "<<origpar<<endl;
cout<<"optimization started at "<<startpar<<endl;
cout<<"Brightness change is "<<std::setprecision(3)<<scale<<" "<<offset<<endl;
return 0;
}