33 #include <Base/Image/Image.hh>
34 #include <Base/ImageUtils/ImageDraw.hh>
35 #include <Base/Image/ImageIO.hh>
36 #include <Base/Image/ImageConvert.hh>
37 #include <Base/Geometry/HomgPoint2D.hh>
38 #include <Base/Debug/TimeMeasure.hh>
39 #include <Image/TextureTransformHomography.hh>
40 #include <Image/TextureTransformSimilar.hh>
41 #include <Image/TextureTransformAffine.hh>
42 #include <Image/TextureTransformDisplacement.hh>
43 #include <Image/TextureTransformDisparity.hh>
44 #include <Base/Math/Random.hh>
46 #include <Matcher2D/ImageAlignment.hh>
47 #include <Image/TextureMapping.hh>
61 BIASERR(
"error loading image "<<name);
66 BIASERR(
"error converting image "<<name);
72 BIASERR(
"error converting image to grey "<<name);
83 int main(
int argc,
char*argv[])
87 cerr << argv[0] <<
" <image> "<< endl;
92 if (LoadImage(argv[1], im[0]) != 0) {
93 BIASERR(
"error loading image " << argv[1]);
109 p[0][2] = p[1][2] = 1.0;
125 cout<<
"Testing HOMOGRAPHY"<<endl;
126 par.
newsize(6); par[0] = 0.1; par[1] = 0.1; par[2] = 0.1; par[3] = 0.1;
127 par[4] = 1; par[5] = -1; par[6] = 0.01; par[7] = -0.01;
130 cout<<
"Testing AFFINITY"<<endl;
131 par.
newsize(6); par[0] = 0.2; par[1] = -0.1; par[2] = -0.2; par[3] = 0.3;
132 par[4] = 1; par[5] = -1;
133 par[0] = cos(0.4)-1.0; par[1] = sin(0.4); par[2] = -sin(0.4); par[3] = cos(0.4)-1.0;
134 par[4] = -2; par[5] = 2;
137 cout<<
"Testing SIMILARITY"<<endl;
138 par.
newsize(4); par[0] = -0.3; par[1] = 0.3; par[2] = 1; par[3] = -1;
break;
140 cout<<
"Testing DISPLACEMENT"<<endl;
141 par.
newsize(2); par[0] = -1; par[1] = 1;
break;
143 cout<<
"Testing DISPARITY"<<endl;
144 par.
newsize(1); par[0]= 1;
break;
149 cout<<
"using parameters "<<par<<endl;
156 cout<<
"setting origin !"<<thepoint2<<endl;
163 cout<<
"setting origin !"<<thepoint2<<endl;
190 bool brightnesschange =
true;
195 *pData = 0.9f * *pData + 20.0f;
196 }
while (pData++ < pDataEnd);
201 double pixelnoise = 0.0;
202 if (pixelnoise>0.0) {
207 }
while (pData++ < pDataEnd);
217 double parameternoise = 0.2;
218 if (parameternoise>0.0) {
219 for (
int i=par.
Size()-1; i>=0; i--) {
221 cov[i][i] = par[i]*par[i]*parameternoise*parameternoise + 1e-10;
230 cout<<
"Setting alignment pixels"<<endl<<flush;
232 cout<<
"Aligning ..."<<endl<<flush;
241 double scale=0, offset=0;
243 cout <<
"result: " << result <<
", "
244 << p[0] <<
" -> " << par <<
", "<<endl;
245 cout<<
"original parameters were "<<origpar<<endl;
246 cout<<
"optimization started at "<<startpar<<endl;
247 cout<<
"Brightness change is "<<std::setprecision(3)<<scale<<
" "<<offset<<endl;
analytic properties of affine image warp
virtual Vector< double > GetInverseParameters() const
returns parameter vector which undoes the current warp
analytic properties of homography transformation of an image
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
void AddDebugLevel(const long int lv)
void SetOrigin(const Vector2< double > &origin)
origin relative to which rotation and scale is performed
analytic properties of x-displacement
void GetLastBrightnessChange(double &scale, double &shift)
return relative affine transform between i1 and i2 if AffineBrightnessInvariance was active ...
void SetAffineBrightnessInvariance(bool bi)
enable brightness variance and offset invariant computation
affine transformation of 2D image plane which relates image coordinate system and local affine featur...
int StrictPyramidAlign(const PyramidImage< float > &I1, const PyramidImage< float > &I2, Vector< double > ¶ms, Matrix< double > &Cov)
aligns image1 with image2 with respect to parameters params, traditional pyramid based alignment is u...
analytic properties of 2D image displacement
Matrix< T > & newsize(Subscript M, Subscript N)
class for representing parameterized image warps, such as homography, displacement, ...
unsigned int Size() const
length of the vector
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
void SetA(const BIAS::Matrix2x2< double > &A, const BIAS::Matrix< double > &cov=BIAS::Matrix< double >(4, 4, BIAS::MatrixZero))
return affine matrix
unsigned int GetWidth() const
void SetAlignmentPixelsRectangular(const LocalAffineFrame &LAF, int numberOfPixels=-1)
choose any rectangular tracking region and resolution
Vector< T > & newsize(Subscript N)
void SetUpdateThreshold(const double maxerr)
if a step smaller (norm L2) than this is taken, convergence is declared and the system finishes ...
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
void SetT(const BIAS::Vector2< double > &T, const BIAS::Matrix< double > &cov=BIAS::Matrix< double >(2, 2, BIAS::MatrixZero))
return offset
void Init(const Image< StorageType > &image, const unsigned py_size=0)
copy image into level 0 and create other levels according to parameters set so far (pyramidsize...
unsigned int GetHeight() const
int Map(const Image< InputStorageType > &src, Image< OutputStorageType > &sink, InterpolationMethod=MapTrilinear, bool newSink=false, double SuperSampling=1.0)
backward mapping with various interpolations
Inverse Compositional Image Alignment ("Registration")
void SetTextureTransform(const TextureTransform &T)
create clone of your texture tranform and set for mapping
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
void SetIdentity()
Converts matrix to identity matrix.
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
virtual void SetParameters(const Vector< double > &p)=0
override the current state with the new parameters, the meaning of the parameters is defined in the d...
void SetOrigin(const Vector2< double > &origin)
origin relative to which rotation and scale is performed
void SetTextureTransform(const TextureTransform &T)
pass object type which holds texture transform
double GetNormalDistributed(const double mean, const double sigma)
on succesive calls return normal distributed random variable with mean and standard deviation sigma ...
void SetDampening(const double &dampening)
adds a dampening d to hessian's diag
void SetMetaData(const MetaData &m)
unsigned long int GetPixelCount() const
returns number of pixels in image
This is the base class for images in BIAS.
Maps source pixel to sink pixel given any TextureTransform.
class for producing random numbers from different distributions
void SetZero()
zeroes the image
void SetMaxIterations(const int maxiter)
number of iterations, before the system stops unsuccessfully
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey