////////////////////////////////////////////////////////////////////////// \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
| 129 | /// \param[out] out downscaled image data |
| 130 | /////////////////////////////////////////////////////////////////////////////// |
| 131 | static void |
| 132 | Downscale(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 |
no test coverage detected