Optimized Belief Propagation (CPU and GPU)
SmoothImageCPU.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 
28 #ifndef SMOOTHIMAGECPU_H_
29 #define SMOOTHIMAGECPU_H_
30 
31 #include <utility>
32 #include <memory>
36 
41 class SmoothImageCPU final : public SmoothImage {
42 public:
43  explicit SmoothImageCPU(const ParallelParams& opt_cpu_params) : SmoothImage(opt_cpu_params) {}
44 
45  //function to use the CPU image filter to apply a guassian filter to the a single images
46  //input images have each pixel stored as an unsigned in (value between 0 and 255 assuming 8-bit grayscale image used)
47  //output filtered images have each pixel stored as a float after the image has been smoothed with a Gaussian filter of sigma
48  void operator()(const BpImage<unsigned int>& in_image, const float sigma, float* smoothed_image) const override;
49 
50 private:
51  //convert the unsigned int pixels to float pixels in an image when
52  //smoothing is not desired but the pixels need to be converted to floats
53  //the input image is stored as unsigned ints in the texture uint_image_pixels
54  //output filtered image stored in float_image_pixels
55  void ConvertUnsignedIntImageToFloatCPU(
56  const unsigned int* uint_image_pixels, float* float_image_pixels,
57  unsigned int width_images, unsigned int height_images,
58  const ParallelParams& opt_cpu_params) const;
59 
60  //apply a horizontal filter on each pixel of the image in parallel
61  template<BpImData_t U>
62  void FilterImageAcrossCPU(
63  const U* image_to_filter, float* filtered_image,
64  unsigned int width_images, unsigned int height_images,
65  const float* image_filter, unsigned int size_filter,
66  const ParallelParams& opt_cpu_params) const;
67 
68  //apply a vertical filter on each pixel of the image in parallel
69  template<BpImData_t U>
70  void FilterImageVerticalCPU(
71  const U* image_to_filter, float* filtered_image,
72  unsigned int width_images, unsigned int height_images,
73  const float* image_filter, unsigned int size_filter,
74  const ParallelParams& opt_cpu_params) const;
75 };
76 
77 #endif /* SMOOTHIMAGECPU_H_ */
Define constraint for data type in belief propagation processing related to image processing.
Declares abstract class for holding and processing parallelization parameters.
Declares class for smoothing the images before running BP.
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...
Child class of SmoothImage for smoothing images in the optimized CPU implementation.
SmoothImageCPU(const ParallelParams &opt_cpu_params)
void operator()(const BpImage< unsigned int > &in_image, const float sigma, float *smoothed_image) const override
Function to use the image filter to apply a guassian filter to the a single image....
Class for smoothing the images before running BP. Smoothing image always uses float data type.
Definition: SmoothImage.h:50