MCPcopy Create free account
hub / github.com/SSARCandy/Coherent-Line-Drawing / gradientDoG

Method gradientDoG

src/CLD.cpp:146–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void CLD::gradientDoG(const cv::Mat &src, cv::Mat &dst, const double rho, const double sigma_c)
147{
148 const double sigma_s = SIGMA_RATIO * sigma_c;
149 std::vector<double> gau_c, gau_s;
150 MakeGaussianVector(sigma_c, gau_c);
151 MakeGaussianVector(sigma_s, gau_s);
152
153 const int kernel = gau_s.size() - 1;
154
155#pragma omp parallel for
156 for (int y = 0; y < dst.rows; ++y) {
157 for (int x = 0; x < dst.cols; ++x) {
158 double gau_c_acc = 0;
159 double gau_s_acc = 0;
160 double gau_c_weight_acc = 0;
161 double gau_s_weight_acc = 0;
162 cv::Vec3f tmp = etf.flowField.at<cv::Vec3f>(y, x);
163 cv::Point2f gradient = cv::Point2f(-tmp[0], tmp[1]);
164
165 if (gradient.x == 0 && gradient.y == 0) continue;
166
167 for (int step = -kernel; step <= kernel; ++step) {
168 const double row = y + gradient.y * step;
169 const double col = x + gradient.x * step;
170
171 if (col > dst.cols - 1 || col < 0.0 || row > dst.rows - 1 || row < 0.0) continue;
172
173 const float value = src.at<float>((int)round(row), (int)round(col));
174
175 const int gau_idx = abs(step);
176 const double gau_c_weight = gau_c[gau_idx];
177 const double gau_s_weight = gau_s[gau_idx];
178
179 gau_c_acc += value * gau_c_weight;
180 gau_s_acc += value * gau_s_weight;
181 gau_c_weight_acc += gau_c_weight;
182 gau_s_weight_acc += gau_s_weight;
183 }
184
185 double v_c = gau_c_acc / gau_c_weight_acc;
186 double v_s = gau_s_acc / gau_s_weight_acc;
187 dst.at<float>(y, x) = v_c - rho * v_s;
188 }
189 }
190}
191
192void CLD::binaryThresholding(const cv::Mat &src, cv::Mat &dst, const double tau)
193{

Callers

nothing calls this directly

Calls 1

MakeGaussianVectorFunction · 0.85

Tested by

no test coverage detected