Debian Codegraph @

Samples/2_Concepts_and_Techniques/imageDenoising/imageDenoising.h

raw symbols SCIP
1 /* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of NVIDIA CORPORATION nor the names of its
12 * contributors may be used to endorse or promote products derived
13 * from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef IMAGE_DENOISING_H
29 #define IMAGE_DENOISING_H
30
31 typedef unsigned int TColor;
32
33 ////////////////////////////////////////////////////////////////////////////////
34 // Filter configuration
35 ////////////////////////////////////////////////////////////////////////////////
36 #define KNN_WINDOW_RADIUS 3
37 #define NLM_WINDOW_RADIUS 3
38 #define NLM_BLOCK_RADIUS 3
39 #define KNN_WINDOW_AREA \
40 ((2 * KNN_WINDOW_RADIUS + 1) * (2 * KNN_WINDOW_RADIUS + 1))
41 #define NLM_WINDOW_AREA \
42 ((2 * NLM_WINDOW_RADIUS + 1) * (2 * NLM_WINDOW_RADIUS + 1))
43 #define INV_KNN_WINDOW_AREA (1.0f / (float)KNN_WINDOW_AREA)
44 #define INV_NLM_WINDOW_AREA (1.0f / (float)NLM_WINDOW_AREA)
45
46 #define KNN_WEIGHT_THRESHOLD 0.02f
47 #define KNN_LERP_THRESHOLD 0.79f
48 #define NLM_WEIGHT_THRESHOLD 0.10f
49 #define NLM_LERP_THRESHOLD 0.10f
50
51 #define BLOCKDIM_X 8
52 #define BLOCKDIM_Y 8
53
54 #ifndef MAX
55 #define MAX(a, b) ((a < b) ? b : a)
56 #endif
57 #ifndef MIN
58 #define MIN(a, b) ((a < b) ? a : b)
59 #endif
60
61 // functions to load images
62 extern "C" void LoadBMPFile(uchar4 **dst, int *width, int *height,
63 const char *name);
64
65 // CUDA wrapper functions for allocation/freeing texture arrays
66 extern "C" cudaTextureObject_t texImage;
67
68 extern "C" cudaError_t CUDA_MallocArray(uchar4 **h_Src, int imageW, int imageH);
69 extern "C" cudaError_t CUDA_FreeArray();
70
71 // CUDA kernel functions
72 extern "C" void cuda_Copy(TColor *d_dst, int imageW, int imageH,
73 cudaTextureObject_t texImage);
74 extern "C" void cuda_KNN(TColor *d_dst, int imageW, int imageH, float Noise,
75 float lerpC, cudaTextureObject_t texImage);
76 extern "C" void cuda_KNNdiag(TColor *d_dst, int imageW, int imageH, float Noise,
77 float lerpC, cudaTextureObject_t texImage);
78 extern "C" void cuda_NLM(TColor *d_dst, int imageW, int imageH, float Noise,
79 float lerpC, cudaTextureObject_t texImage);
80 extern "C" void cuda_NLMdiag(TColor *d_dst, int imageW, int imageH, float Noise,
81 float lerpC, cudaTextureObject_t texImage);
82
83 extern "C" void cuda_NLM2(TColor *d_dst, int imageW, int imageH, float Noise,
84 float LerpC, cudaTextureObject_t texImage);
85 extern "C" void cuda_NLM2diag(TColor *d_dst, int imageW, int imageH,
86 float Noise, float LerpC,
87 cudaTextureObject_t texImage);
88
89 #endif