| 
1 | 1 | //Vladimir Gudkov, Ilia Moiseev  | 
2 | 2 | //South Ural State University, Chelyabinsk, Russia, 2020  | 
3 | 3 | //Image smoothing Algorithm Based on Gradient Analysis  | 
 | 4 | +/*  | 
 | 5 | +Functions and classes in this file use the template system.  | 
 | 6 | +The names of template arguments are the tips that were made to help user  | 
 | 7 | +in choosing the data types that are recommended to use (in parenthesis):  | 
 | 8 | +	Tf - floating point number (float or double)  | 
 | 9 | +	Ts - signed integer (int32_t)  | 
 | 10 | +	Tu - unsigned integer (uint8_t)  | 
 | 11 | +*/  | 
4 | 12 | 
 
  | 
5 | 13 | #include "stdint.h"  | 
6 | 14 | #include <cmath>  | 
@@ -75,18 +83,30 @@ void computeModules(Tu*** src, Tf*** dst, Ts**** grads, uint32_t height, uint32_  | 
75 | 83 | 				dst[i][j][c] = module<Tf, Ts>(grads[i][j][c]);  | 
76 | 84 | }  | 
77 | 85 | 
 
  | 
 | 86 | +//The class that implements filtering. To use it create an instance of Filter class   | 
 | 87 | +//and then call operator ()  | 
78 | 88 | template<typename Tf, typename Tu>  | 
79 | 89 | class Filter  | 
80 | 90 | {  | 
81 | 91 | public:  | 
 | 92 | +	/*  | 
 | 93 | +		Operator () filters src with kernel of size ksize, then leaves result in dst image.  | 
 | 94 | + | 
 | 95 | +		Recieves:  | 
 | 96 | +		Tu*** src - source image, array with the shape (height x width x colors)  | 
 | 97 | +		Tf*** dst - destination image with the same shape as src  | 
 | 98 | +		Tf*** modules - the array of gradient modules with the same shape as src  | 
 | 99 | +		Tf*** modules - the array of gradient modules with the same shape as src  | 
 | 100 | +		uint32_t ksize - size of filtering kernel (odd values expected)  | 
 | 101 | +		uint32_t height, width, colors - dimensions of the src image  | 
 | 102 | +	*/  | 
82 | 103 | 	void operator()(Tu*** src, Tf*** dst, Tf*** modules, Tf*** angles,  | 
83 | 104 | 		uint32_t ksize, uint32_t height, uint32_t width, uint32_t colors)  | 
84 | 105 | 	{  | 
85 | 106 | 		for (uint32_t c = 0; c < colors; c++)  | 
86 | 107 | 			for (uint32_t i = 0; i < height; i++)  | 
87 | 108 | 				for (uint32_t j = 0; j < width; j++)  | 
88 | 109 | 				{		  | 
89 |  | - | 
90 | 110 | 					int up = i - ksize / 2;  | 
91 | 111 | 					int left = j - ksize / 2;  | 
92 | 112 | 					int down = i + ksize / 2 + 1;  | 
 | 
0 commit comments