40 in_image.
Width(), in_image.
Height(), this->parallel_params_);
49 std::unique_ptr<float[]> intermediateImage = std::make_unique<float[]>(in_image.
Width() * in_image.
Height());
53 in_image.
Height(), filter.data(), filter.size(), this->parallel_params_);
56 FilterImageVerticalCPU<float>(intermediateImage.get(), smoothed_image,
57 in_image.
Width(), in_image.
Height(), filter.data(), filter.size(), this->parallel_params_);
65 void SmoothImageCPU::ConvertUnsignedIntImageToFloatCPU(
66 const unsigned int* uint_image_pixels,
float* float_image_pixels,
67 unsigned int width_images,
unsigned int height_images,
70 #if defined(SET_THREAD_COUNT_INDIVIDUAL_KERNELS_CPU)
71 int num_threads_kernel{
73 #pragma omp parallel for num_threads(num_threads_kernel)
75 #pragma omp parallel for
78 for (
int val = 0; val < width_images * height_images; val++) {
80 for (
unsigned int val = 0; val < width_images * height_images; val++) {
82 const unsigned int y_val = val / width_images;
83 const unsigned int x_val = val % width_images;
84 float_image_pixels[y_val * width_images + x_val] = 1.0f * uint_image_pixels[y_val * width_images + x_val];
90 template<BpImData_t U>
91 void SmoothImageCPU::FilterImageAcrossCPU(
92 const U* image_to_filter,
float* filtered_image,
93 unsigned int width_images,
unsigned int height_images,
94 const float* image_filter,
unsigned int size_filter,
97 #if defined(SET_THREAD_COUNT_INDIVIDUAL_KERNELS_CPU)
98 int num_threads_kernel{
101 #pragma omp parallel for num_threads(num_threads_kernel)
103 #pragma omp parallel for
106 for (
int val = 0; val < width_images * height_images; val++) {
108 for (
unsigned int val = 0; val < width_images * height_images; val++) {
110 const unsigned int y_val = val / width_images;
111 const unsigned int x_val = val % width_images;
112 beliefprop::FilterImageAcrossProcessPixel<U>(
113 x_val, y_val, image_to_filter, filtered_image,
114 width_images, height_images, image_filter, size_filter);
119 template<BpImData_t U>
120 void SmoothImageCPU::FilterImageVerticalCPU(
121 const U* image_to_filter,
float* filtered_image,
122 unsigned int width_images,
unsigned int height_images,
123 const float* image_filter,
unsigned int size_filter,
126 #if defined(SET_THREAD_COUNT_INDIVIDUAL_KERNELS_CPU)
127 int num_threads_kernel{
129 #pragma omp parallel for num_threads(num_threads_kernel)
131 #pragma omp parallel for
134 for (
int val = 0; val < width_images * height_images; val++) {
136 for (
unsigned int val = 0; val < width_images * height_images; val++) {
138 const unsigned int y_val = val / width_images;
139 const unsigned int x_val = val % width_images;
140 beliefprop::FilterImageVerticalProcessPixel<U>(
141 x_val, y_val, image_to_filter, filtered_image,
142 width_images, height_images, image_filter, size_filter);
152 template void SmoothImageCPU::FilterImageAcrossCPU<float>(
153 const float* image_to_filter,
float* filtered_image,
154 unsigned int width_images,
unsigned int height_images,
155 const float* image_filter,
unsigned int size_filter,
157 template void SmoothImageCPU::FilterImageAcrossCPU<unsigned int>(
158 const unsigned int* image_to_filter,
float* filtered_image,
159 unsigned int width_images,
unsigned int height_images,
160 const float* image_filter,
unsigned int size_filter,
165 template void SmoothImageCPU::FilterImageVerticalCPU<float>(
166 const float* image_to_filter,
float* filtered_image,
167 unsigned int width_images,
unsigned int height_images,
168 const float* image_filter,
unsigned int size_filter,
170 template void SmoothImageCPU::FilterImageVerticalCPU<unsigned int>(
171 const unsigned int* image_to_filter,
float* filtered_image,
172 unsigned int width_images,
unsigned int height_images,
173 const float* image_filter,
unsigned int size_filter,
Functions for smoothing input images that are used in both optimized CPU and CUDA implementations.
constexpr float kMinSigmaValSmooth
Declares child class of SmoothImage for smoothing images in the optimized CPU implementation.
Class to define images that are used in bp processing.
unsigned int Height() const
unsigned int Width() const
T * PointerToPixelsStart() const
Abstract class for holding and processing parallelization parameters. Child class(es) specific to im...
virtual std::array< unsigned int, 2 > OptParamsForKernel(const std::array< unsigned int, 2 > &kernel_location) const =0
Get optimized parallel parameters for parallel processing kernel for kernel that is indexed as an arr...
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....
std::vector< float > MakeFilter(float sigma) const
Create a Gaussian filter from a sigma value.