MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / WarpImage

Function WarpImage

cpp/5_Domain_Specific/HSOpticalFlow/flowGold.cpp:200–212  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// \brief warp image with provided vector field For each output pixel there is a vector which tells which pixel from a source image should be mapped to this particular output pixel. It is assumed that images and the vector field have the same stride and resolution. \param[in] src source image \param[in] w width \param[in]

Source from the content-addressed store, hash-verified

198/// \param[out] out warped image
199///////////////////////////////////////////////////////////////////////////////
200static void WarpImage(const float *src, int w, int h, int s, const float *u, const float *v, float *out)
201{
202 for (int i = 0; i < h; ++i) {
203 for (int j = 0; j < w; ++j) {
204 const int pos = j + i * s;
205 // warped coords
206 float x = (float)j + u[pos];
207 float y = (float)i + v[pos];
208
209 out[pos] = Tex2D(src, w, h, s, x, y);
210 }
211 }
212}
213
214///////////////////////////////////////////////////////////////////////////////
215/// \brief computes image derivatives for a pair of images

Callers 1

ComputeFlowGoldFunction · 0.85

Calls 1

Tex2DFunction · 0.85

Tested by

no test coverage detected