void UndistortImage( const Image& imageIn, const IntrinsicBase * cam, Image & image_ud, typename Image::Tpixel fillcolor = typename Image::Tpixel(0)) { if (!cam->have_disto()) // no distortion, perform a direct copy { image_ud = imageIn; } else // There is distortion { image_ud.resize(imageIn.Width(), imageIn.Height(), true, fillcolor); const image::Sampler2d<image::SamplerLinear> sampler; #ifdef OPENMVG_USE_OPENMP #pragma omp parallel for #endif for (int j = 0; j < imageIn.Height(); ++j) for (int i = 0; i < imageIn.Width(); ++i) { const Vec2 undisto_pix(i,j); // compute coordinates with distortion const Vec2 disto_pix = cam->get_d_pixel(undisto_pix); // pick pixel if it is in the image domain if ( imageIn.Contains(disto_pix(1), disto_pix(0)) ) image_ud( j, i ) = sampler(imageIn, disto_pix(1), disto_pix(0)); } } }
void Warp(const Image &im, const Mat3 & H, Image &out) { const int wOut = static_cast<int>(out.Width()); const int hOut = static_cast<int>(out.Height()); for (int j = 0; j < hOut; ++j) #ifdef USE_OPENMP #pragma omp parallel for #endif for (int i = 0; i < wOut; ++i) { double xT = i, yT = j; if (ApplyH_AndCheckOrientation(H, xT, yT) && im.Contains(yT,xT)) out(j,i) = SampleLinear(im, (float)yT, (float)xT); } }