| 471 | } |
| 472 | |
| 473 | void MultiscaleDenoiser::interpolate(Deepimf& o_rInterpolatedImage, const Deepimf& i_rImage) |
| 474 | { |
| 475 | const int width = i_rImage.getWidth(); |
| 476 | const int height = i_rImage.getHeight(); |
| 477 | const int depth = i_rImage.getDepth(); |
| 478 | const int upscaledWidth = o_rInterpolatedImage.getWidth(); |
| 479 | const int upscaledHeight = o_rInterpolatedImage.getHeight(); |
| 480 | |
| 481 | assert(width == upscaledWidth / 2); |
| 482 | assert(height == upscaledHeight / 2); |
| 483 | assert(depth == o_rInterpolatedImage.getDepth()); |
| 484 | |
| 485 | const float mainPixelWeight = 9.f / 16.f; |
| 486 | const float adjacentPixelWeight = 3.f / 16.f; |
| 487 | const float diagonalPixelWeight = 1.f / 16.f; |
| 488 | |
| 489 | int upscaledLine, upscaledCol, z, line, col, adjacentLine, adjacentCol; |
| 490 | |
| 491 | for(upscaledLine = 0; upscaledLine < upscaledHeight; ++upscaledLine) |
| 492 | for(upscaledCol = 0; upscaledCol < upscaledWidth; ++upscaledCol) |
| 493 | { |
| 494 | line = upscaledLine / 2; |
| 495 | col = upscaledCol / 2; |
| 496 | adjacentLine = clampPositiveInteger(line + ((upscaledLine % 2) * 2 - 1), height); |
| 497 | adjacentCol = clampPositiveInteger(col + ((upscaledCol % 2) * 2 - 1), width); |
| 498 | for(z = 0; z < depth; ++z) |
| 499 | { |
| 500 | const PixelPosition p1 = i_rImage.clamp(PixelPosition(line, col)); |
| 501 | const PixelPosition p2 = i_rImage.clamp(PixelPosition(line, adjacentCol)); |
| 502 | const PixelPosition p3 = i_rImage.clamp(PixelPosition(adjacentLine, col)); |
| 503 | const PixelPosition p4 = i_rImage.clamp(PixelPosition(adjacentLine, adjacentCol)); |
| 504 | |
| 505 | o_rInterpolatedImage.set(upscaledLine, upscaledCol, z, |
| 506 | mainPixelWeight * i_rImage.get(p1, z) + |
| 507 | adjacentPixelWeight * (i_rImage.get(p2, z) + i_rImage.get(p3, z)) + |
| 508 | diagonalPixelWeight * i_rImage.get(p4, z)); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | } |
| 513 | |
| 514 | void MultiscaleDenoiser::downscale(Deepimf& o_rDownscaledImage, const Deepimf& i_rImage) |
| 515 | { |
nothing calls this directly
no test coverage detected