@@ -217,14 +217,16 @@ struct LensDistortBrown1 : public CoordonatesSystem<F>
217217 BOOST_ASSERT ( this ->_params .distort );
218218 BOOST_ASSERT ( this ->_params .coef1 >= 0 );
219219 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) ); // centered normalized space
220- pc *= this ->_params .postScale ;
220+ pc.x *= this ->_params .postScale .x ;
221+ pc.y *= this ->_params .postScale .y ;
221222
222223 const F r2 = pc.x * pc.x + pc.y * pc.y ; // distance to center squared
223224 const F coef = 1.0 + r2 * this ->_params .coef1 ; // distortion coef for current pixel
224225 pc.x *= coef;
225226 pc.y *= coef;
226227
227- pc *= this ->_params .preScale ;
228+ pc.x *= this ->_params .preScale .x ;
229+ pc.y *= this ->_params .preScale .y ;
228230 return this ->lensCenterNormalizedToPixel ( pc ); // original space
229231 }
230232};
@@ -242,7 +244,8 @@ struct LensUndistortBrown1 : public CoordonatesSystem<F>
242244 BOOST_ASSERT ( this ->_params .coef1 >= 0 );
243245 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) );
244246
245- pc *= this ->_params .postScale ;
247+ pc.x *= this ->_params .postScale .x ;
248+ pc.y *= this ->_params .postScale .y ;
246249
247250 F r = std::sqrt ( pc.x * pc.x + pc.y * pc.y ); // distance to center
248251
@@ -282,10 +285,12 @@ struct LensUndistortBrown1 : public CoordonatesSystem<F>
282285
283286 // get coordinates into distorded image from distorded center
284287 coef /= r;
285- coef = std::abs ( coef );
288+ coef = std::abs ( coef );
289+ pc.x *= coef;
290+ pc.y *= coef;
286291
287- pc *= coef ;
288- pc *= this ->_params .preScale ;
292+ pc. x *= this -> _params . preScale . x ;
293+ pc. y *= this ->_params .preScale . y ;
289294 return this ->lensCenterNormalizedToPixel ( pc ); // to the original space
290295 }
291296};
@@ -303,14 +308,17 @@ struct LensDistortBrown3 : public CoordonatesSystem<F>
303308 {
304309 BOOST_ASSERT ( this ->_params .distort );
305310 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) ); // centered normalized space
306- pc *= this ->_params .postScale ;
311+ pc.x *= this ->_params .postScale .x ;
312+ pc.y *= this ->_params .postScale .y ;
307313
308314 const F r2 = pc.x * pc.x + pc.y * pc.y ; // distance to center squared
309315 // distortion coef for current pixel
310316 const F coef = distoCoef ( this ->_params , r2 );
311- pc *= coef;
317+ pc.x *= coef;
318+ pc.y *= coef;
312319
313- pc *= this ->_params .preScale ;
320+ pc.x *= this ->_params .preScale .x ;
321+ pc.y *= this ->_params .preScale .y ;
314322 return this ->lensCenterNormalizedToPixel ( pc ); // original space
315323 }
316324
@@ -335,18 +343,20 @@ struct LensUndistortBrown3 : public CoordonatesSystem<F>
335343 {
336344 BOOST_ASSERT ( !this ->_params .distort );
337345 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) );
338- pc *= this ->_params .postScale ;
346+ pc.x *= this ->_params .postScale .x ;
347+ pc.y *= this ->_params .postScale .y ;
339348
340349 const F r2 = pc.x * pc.x + pc.y * pc.y ; // distance to center squared
341350 const LensDistortBrown3<F> distortion (this ->_params );
342351 const DistoSolver<LensDistortBrown3<F> > distortionSolver (distortion);
343352 const F coefSolver = bisectionRadiusSolve (r2, distortionSolver);
344353
345354 const F coef = (r2 == 0 ) ? 1 . : std::sqrt (coefSolver / r2);
355+ pc.x *= coef;
356+ pc.y *= coef;
346357
347- pc *= coef;
348-
349- pc *= this ->_params .preScale ;
358+ pc.x *= this ->_params .preScale .x ;
359+ pc.y *= this ->_params .preScale .y ;
350360 return this ->lensCenterNormalizedToPixel ( pc ); // to the original space
351361 }
352362};
@@ -364,14 +374,17 @@ struct LensDistortPTLens : public CoordonatesSystem<F>
364374 BOOST_ASSERT ( this ->_params .distort );
365375 BOOST_ASSERT ( this ->_params .coef1 >= 0 );
366376 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) ); // centered normalized space
367- pc *= this ->_params .postScale ;
377+ pc.x *= this ->_params .postScale .x ;
378+ pc.y *= this ->_params .postScale .y ;
368379
369380 const F r2 = pc.x * pc.x + pc.y * pc.y ; // distance to center squared
370381 // distortion coef for current pixel
371382 const F coef = distoCoef ( this ->_params , r2 );
372- pc *= coef;
383+ pc.x *= coef;
384+ pc.y *= coef;
373385
374- pc *= this ->_params .preScale ;
386+ pc.x *= this ->_params .preScale .x ;
387+ pc.y *= this ->_params .preScale .y ;
375388 return this ->lensCenterNormalizedToPixel ( pc ); // original space
376389 }
377390
@@ -396,18 +409,20 @@ struct LensUndistortPTLens : public CoordonatesSystem<F>
396409 BOOST_ASSERT ( !this ->_params .distort );
397410 BOOST_ASSERT ( this ->_params .coef1 >= 0 );
398411 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) );
399- pc *= this ->_params .postScale ;
412+ pc.x *= this ->_params .postScale .x ;
413+ pc.y *= this ->_params .postScale .y ;
400414
401415 const F r2 = pc.x * pc.x + pc.y * pc.y ; // distance to center squared
402416 const LensDistortPTLens<F> disto (this ->_params );
403417 const DistoSolver<LensDistortPTLens<F> > distoSolver (disto);
404418 const F coefSolver = bisectionRadiusSolve (r2, distoSolver);
405419
406420 const F coef = (r2 == 0 ) ? 1 . : std::sqrt (coefSolver / r2);
421+ pc.x *= coef;
422+ pc.y *= coef;
407423
408- pc *= coef;
409-
410- pc *= this ->_params .preScale ;
424+ pc.x *= this ->_params .preScale .x ;
425+ pc.y *= this ->_params .preScale .y ;
411426 return this ->lensCenterNormalizedToPixel ( pc ); // to the original space
412427 }
413428};
@@ -423,18 +438,21 @@ struct LensDistortFisheye : public CoordonatesSystem<F>
423438 inline point2<F> apply ( const point2<F2>& src ) const
424439 {
425440 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) );
426- pc *= this ->_params .postScale ;
441+ pc.x *= this ->_params .postScale .x ;
442+ pc.y *= this ->_params .postScale .y ;
427443
428444 F r = std::sqrt ( pc.x * pc.x + pc.y * pc.y ); // distance to center
429445 if ( r == 0 )
430446 {
431447 point2<F> tmp ( src.x , src.y );
432448 return tmp;
433449 }
434- F coef = 0.5 * std::tan ( r * this ->_params .coef1 ) / ( std::tan ( 0.5 * this ->_params .coef1 ) * r );
450+ const F coef = 0.5 * std::tan ( r * this ->_params .coef1 ) / ( std::tan ( 0.5 * this ->_params .coef1 ) * r );
451+ pc.x *= coef;
452+ pc.y *= coef;
435453
436- pc *= coef ;
437- pc *= this ->_params .preScale ;
454+ pc. x *= this -> _params . preScale . x ;
455+ pc. y *= this ->_params .preScale . y ;
438456 return this ->lensCenterNormalizedToPixel ( pc ); // to the original space
439457 }
440458};
@@ -449,7 +467,8 @@ struct LensUndistortFisheye : public CoordonatesSystem<F>
449467 inline point2<F> apply ( const point2<F2>& src ) const
450468 {
451469 point2<F> pc ( this ->pixelToLensCenterNormalized ( src ) );
452- pc *= this ->_params .postScale ;
470+ pc.x *= this ->_params .postScale .x ;
471+ pc.y *= this ->_params .postScale .y ;
453472
454473 F r = std::sqrt ( pc.x * pc.x + pc.y * pc.y ); // distance to center
455474 if ( r == 0 || this ->_params .coef1 == 0 )
@@ -459,9 +478,11 @@ struct LensUndistortFisheye : public CoordonatesSystem<F>
459478 }
460479 F coef = std::atan ( 2.0 * r * std::tan ( 0.5 * this ->_params .coef1 ) ) / this ->_params .coef1 ;
461480 coef /= r;
481+ pc.x *= coef;
482+ pc.y *= coef;
462483
463- pc *= coef ;
464- pc *= this ->_params .preScale ;
484+ pc. x *= this -> _params . preScale . x ;
485+ pc. y *= this ->_params .preScale . y ;
465486 return this ->lensCenterNormalizedToPixel ( pc ); // to the original space
466487 }
467488};
0 commit comments