Optimized Belief Propagation (CPU and GPU)
SmoothImage.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2024 Scott Grauer-Gray
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
27 #ifndef SMOOTH_IMAGE_HOST_HEADER_H
28 #define SMOOTH_IMAGE_HOST_HEADER_H
29 
30 #include <cmath>
31 #include <memory>
32 #include <utility>
33 #include <algorithm>
36 #include "BpImage.h"
37 
38 //don't smooth input images if kSigmaBp below this
39 constexpr float kMinSigmaValSmooth{0.1f};
40 
41 //parameter for smoothing
42 constexpr float kWidthSigma1{4.0f};
43 
50 {
51 public:
52  explicit SmoothImage(const ParallelParams& parallel_params) : parallel_params_{parallel_params} {}
53 
67  virtual void operator()(
68  const BpImage<unsigned int>& in_image,
69  float sigma,
70  float* smoothed_image) const = 0;
71 
72 protected:
79  std::vector<float> MakeFilter(float sigma) const;
80 
87 
88 private:
95  void NormalizeFilter(std::vector<float>& filter) const;
96 };
97 
98 #endif //SMOOTH_IMAGE_HOST_HEADER_H
File with namespace for enums, constants, structures, and functions specific to belief propagation pr...
Declares class to define images that are used in bp processing.
Declares child class of ParallelParams to store and process parallelization parameters to use in each...
constexpr float kWidthSigma1
Definition: SmoothImage.h:42
constexpr float kMinSigmaValSmooth
Definition: SmoothImage.h:39
Class to define images that are used in bp processing.
Definition: BpImage.h:56
Abstract class for holding and processing parallelization parameters. Child class(es) specific to im...
Class for smoothing the images before running BP. Smoothing image always uses float data type.
Definition: SmoothImage.h:50
virtual void operator()(const BpImage< unsigned int > &in_image, float sigma, float *smoothed_image) const =0
Function to use the image filter to apply a guassian filter to the a single image....
SmoothImage(const ParallelParams &parallel_params)
Definition: SmoothImage.h:52
const ParallelParams & parallel_params_
Parallel parameters to use parallel operations (number of threads on CPU / thread block config in CUD...
Definition: SmoothImage.h:86
std::vector< float > MakeFilter(float sigma) const
Create a Gaussian filter from a sigma value.
Definition: SmoothImage.cpp:30