17 #include "SimpleOpt.h"
24 {
OPT_XC, _T(
"-xc"), SO_REQ_SEP },
25 {
OPT_YC, _T(
"-yc"), SO_REQ_SEP },
26 {
OPT_K1, _T(
"-k1"), SO_REQ_SEP },
27 {
OPT_K2, _T(
"-k2"), SO_REQ_SEP },
28 {
OPT_K3, _T(
"-k3"), SO_REQ_SEP },
32 {
OPT_POINTS, _T(
"--reference-points"), SO_NONE },
54 void k(
double k1,
double k2,
double k3) {
k1_=k1;
k2_=k2;
k3_=k3;}
59 double rdefo(
double rexact);
86 rn =
k0_*rest+
k1_*rest*rest+
k2_*rest*rest*rest+
k3_*rest*rest*rest*rest;
87 double rnd =
k0_+2*
k1_*rest+3*
k2_*rest*rest+4*
k3_*rest*rest*rest;
88 double dr = (rexact-rn)/rnd;
90 }
while ((fabs(rexact-rn)>1.e-5)&&(
n<n_max));
93 std::cerr <<
"convergence problem!" << std::endl;
94 std::cerr <<
"are the factors large? check result carefully." << std::endl;
95 std::cerr <<
"rest: " << fabs(rexact-rn) << std::endl;
105 double r = sqrt(dx*dx+dy*dy)/
r_max_;
115 double r = sqrt(dx*dx+dy*dy)/
r_max_;
120 if (L == -1.)
return false;
127 if (xo<(
double)
box_in_[0])
return false;
128 if (xo>(
double)
box_in_[1])
return false;
129 if (yo<(
double)
box_in_[2])
return false;
130 if (yo>(
double)
box_in_[3])
return false;
136 #include "unwarp.help"
140 int main(
int argc,
char ** argv)
147 bool is_scaled=
false;
150 bool with_points =
false;
154 if (args.LastError() == SO_SUCCESS)
162 else if (args.OptionId() ==
OPT_XC)
164 std::ostringstream o;
165 o << args.OptionArg();
166 std::istringstream
in(o.str().c_str());
169 }
else if (args.OptionId() ==
OPT_YC)
171 std::ostringstream o;
172 o << args.OptionArg();
173 std::istringstream
in(o.str().c_str());
176 }
else if (args.OptionId() ==
OPT_K1)
178 std::ostringstream o;
179 o << args.OptionArg();
180 std::istringstream
in(o.str().c_str());
182 }
else if (args.OptionId() ==
OPT_K2)
184 std::ostringstream o;
185 o << args.OptionArg();
186 std::istringstream
in(o.str().c_str());
188 }
else if (args.OptionId() ==
OPT_K3)
190 std::ostringstream o;
191 o << args.OptionArg();
192 std::istringstream
in(o.str().c_str());
198 std::cerr <<
"Invalid argument: " << args.OptionText() << std::endl;
199 return error(args.LastError());
204 if (args.FileCount() != 2)
return error(-2);
205 std::ifstream
in(args.File(0));
208 std::cerr <<
"cannot open file: '" << args.File(0) <<
"'" << std::endl;
213 disto.
read(args.File(0));
216 double d = disto.
diag();
222 if (given_xc) disto.
xc(xc);
223 if (given_yc) disto.
yc(yc);
227 disto.
write(args.File(1));
232 std::cout << npts << std::endl;
233 for (
unsigned int i=0; i<npts; i++)
239 std::cout << un <<
" " << vn << std::endl;
a unit to deform an image. The transformation function needs to be defined in a children class.
void write(const std::string &name)
write the processed image to a file
void deform()
deform the image
virtual void read(const std::string &name)
read the image to be processed
virtual void box_out()
compute the bounding box of the new image
void centre(double xc, double yc)
void box_out()
compute the bounding box of the new image
void new_coordinates(double xo, double yo, double &xn, double &yn)
gives the pixel coordinates in the output image in function of the pixel coordinates in the input ima...
double rdefo(double rexact)
bool old_coordinates(double xn, double yn, double &xo, double &yo)
gives the pixel coordinates in the input image in function of the pixel coordinates in the output ima...
void k(double k1, double k2, double k3)
void read(const std::string &name)
read the image to be processed
double v(const uint32_t step, const uint32_t n)
CSimpleOpt::SOption g_rgOptions[]
int main(int argc, char **argv)