1 // This file comes from the original BCD implementation,
2 // with minor changes to remove dependencies, unused code
3 // and re-formatting. Original license follows:
4 
5 // This file is part of the reference implementation for the paper
6 //   Bayesian Collaborative Denoising for Monte-Carlo Rendering
7 //   Malik Boughida and Tamy Boubekeur.
8 //   Computer Graphics Forum (Proc. EGSR 2017), vol. 36, no. 4, p. 137-153, 2017
9 //
10 // All rights reserved. Use of this source code is governed by a
11 // BSD-style license that can be found in the LICENSE.txt file.
12 
13 #ifndef SPIKE_REMOVAL_FILTER_H
14 #define SPIKE_REMOVAL_FILTER_H
15 
16 // Standard headers.
17 #include <vector>
18 
19 namespace bcd
20 {
21 
22 template<typename T>
23 class DeepImage;
24 
25 class SpikeRemovalFilter
26 {
27   public:
28     static void filter(
29         DeepImage<float>&           io_rInputColorImage,
30         DeepImage<float>&           io_rInputNbOfSamplesImage,
31         DeepImage<float>&           io_rInputHistogramImage,
32         DeepImage<float>&           io_rInputCovImage,
33         float                       i_thresholdStDevFactor = 2.f);
34 
35     static void filter(
36         DeepImage<float>&           io_rInputColorImage,
37         float                       i_thresholdStDevFactor = 2.f);
38 
39   private:
40     static void computeAverageAndStandardDeviation(
41         float&                      o_rAverage,
42         float&                      o_rStandardDeviation,
43         const std::vector<float>&   i_rData);
44 
45     //  Simple and expensive (quadratic) implementation of multi-dimensional
46     //  median as the minimizer of L1 distance among elements
47     static int compute3DMedianIndex(
48         const std::vector<float>&   i_rDataR,
49         const std::vector<float>&   i_rDataG,
50         const std::vector<float>&   i_rDataB);
51 };
52 
53 } // namespace bcd
54 
55 #endif
56