212 {
213 using namespace std;
214
215
216 typedef typename Field_T::value_type Data_T;
218
219
221
222
223 const float tgtToSrcMult = 2.0;
224 const float filterCoordMult = 1.0f / (tgtToSrcMult);
225
226
228
229
230 size_t idx;
231 {
232 boost::mutex::scoped_lock lock(
m_mutex);
235 }
236
238
240
242
243 for (int k = box.min.z; k <= box.max.z; ++k) {
244 for (int j = box.min.y; j <= box.max.y; ++j) {
245 for (int i = box.min.x; i <= box.max.x; ++i) {
246 Value_T accumValue(
m_filterOp.initialValue());
247 if (IsAnalytic_T) {
248
249 const int curTgt =
V3i(i, j, k)[
m_dim];
251
252 int startSrc =
253 static_cast<int>(std::floor(curSrc - support * tgtToSrcMult));
254 int endSrc =
255 static_cast<int>(std::ceil(curSrc + support *
256 tgtToSrcMult)) - 1;
257
258 startSrc = std::max(startSrc, srcDw.min[
m_dim]);
259 endSrc = std::min(endSrc, srcDw.max[
m_dim]);
260
261 for (int s = startSrc; s <= endSrc; ++s) {
262
263 const int xIdx =
m_dim == 0 ? s : i;
264 const int yIdx =
m_dim == 1 ? s : j;
265 const int zIdx =
m_dim == 2 ? s : k;
266
268
269 const float weight =
m_filterOp.eval(std::abs(srcP - curSrc) *
270 filterCoordMult);
271
272 const Value_T value =
m_src.fastValue(xIdx, yIdx, zIdx);
273
274 if (weight > 0.0f) {
275 FilterOp_T::op(accumValue, value);
276 }
277 }
278
279 if (accumValue !=
280 static_cast<Value_T
>(
m_filterOp.initialValue())) {
281 m_tgt.fastLValue(i, j, k) = accumValue;
282 }
283 } else {
284 float accumWeight = 0.0f;
285
286 const int curTgt =
V3i(i, j, k)[
m_dim];
288
289 int startSrc =
290 static_cast<int>(std::floor(curSrc - support * tgtToSrcMult));
291 int endSrc =
292 static_cast<int>(std::ceil(curSrc + support *
293 tgtToSrcMult)) - 1;
294
295 startSrc = std::max(startSrc, srcDw.min[
m_dim]);
296 endSrc = std::min(endSrc, srcDw.max[
m_dim]);
297
298 for (int s = startSrc; s <= endSrc; ++s) {
299
300 const int xIdx =
m_dim == 0 ? s : i;
301 const int yIdx =
m_dim == 1 ? s : j;
302 const int zIdx =
m_dim == 2 ? s : k;
303
305
306 const float weight =
m_filterOp.eval(std::abs(srcP - curSrc) *
307 filterCoordMult);
308
309 const Value_T value =
m_src.fastValue(xIdx, yIdx, zIdx);
310
311 accumWeight += weight;
312 accumValue += value * weight;
313 }
314
315 if (accumWeight > 0.0f &&
316 accumValue != static_cast<Value_T>(0.0)) {
317 m_tgt.fastLValue(i, j, k) = accumValue / accumWeight;
318 }
319 }
320 }
321 }
322 }
323 }
324
325 {
326 boost::mutex::scoped_lock lock(
m_mutex);
329 }
330 }
331 }
double discToCont(int discCoord)
Goes from discrete coordinates to continuous coordinates See Graphics Gems - What is a pixel.
bool checkInputEmpty(const SparseField< Data_T > &src, const SparseField< Data_T > &, const Box3i &tgtBox, const float support, const size_t dim)