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

Function Downscale

cpp/5_Domain_Specific/HSOpticalFlow/flowGold.cpp:131–149  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// \brief resize image \param[in] src image to downscale \param[in] width image width \param[in] height image height \param[in] stride image stride \param[in] newWidth image new width \param[in] newHeight image new height \param[in] newStride image new stride \param[out] out downsc

Source from the content-addressed store, hash-verified

129/// \param[out] out downscaled image data
130///////////////////////////////////////////////////////////////////////////////
131static void
132Downscale(const float *src, int width, int height, int stride, int newWidth, int newHeight, int newStride, float *out)
133{
134 for (int i = 0; i < newHeight; ++i) {
135 for (int j = 0; j < newWidth; ++j) {
136 const int srcX = j * 2;
137 const int srcY = i * 2;
138 // average 4 neighbouring pixels
139 float sum;
140 sum = Tex2Di(src, width, height, stride, srcX + 0, srcY + 0);
141 sum += Tex2Di(src, width, height, stride, srcX + 0, srcY + 1);
142 sum += Tex2Di(src, width, height, stride, srcX + 1, srcY + 0);
143 sum += Tex2Di(src, width, height, stride, srcX + 1, srcY + 1);
144 // normalize
145 sum *= 0.25f;
146 out[j + i * newStride] = sum;
147 }
148 }
149}
150
151///////////////////////////////////////////////////////////////////////////////
152/// \brief upscale one component of a displacement field

Callers 1

ComputeFlowGoldFunction · 0.85

Calls 1

Tex2DiFunction · 0.85

Tested by

no test coverage detected