314 float tHigh = hysteresis_threshold_high_;
315 float tLow = hysteresis_threshold_low_;
316 const int height = input_->height;
317 const int width = input_->width;
319 output.
resize(height * width);
321 output.
width = width;
326 kernel_.setKernelSize(3);
327 kernel_.setKernelSigma(1.0);
329 kernel_.fetchKernel(*gaussian_kernel);
330 convolution_.setKernel(*gaussian_kernel);
331 convolution_.setInputCloud(input_);
332 convolution_.filter(*smoothed_cloud);
336 setInputCloud(smoothed_cloud);
337 detectEdgeSobel(*edges);
340 discretizeAngles(*edges);
344 suppressNonMaxima(*edges, *maxima, tLow);
347 for (
int i = 0; i < height; i++) {
348 for (
int j = 0; j < width; j++) {
349 if ((*maxima)(j, i).intensity < tHigh ||
350 (*maxima)(j, i).intensity == std::numeric_limits<float>::max())
353 (*maxima)(j, i).intensity = std::numeric_limits<float>::max();
354 cannyTraceEdge(1, 0, i, j, *maxima);
355 cannyTraceEdge(-1, 0, i, j, *maxima);
356 cannyTraceEdge(1, 1, i, j, *maxima);
357 cannyTraceEdge(-1, -1, i, j, *maxima);
358 cannyTraceEdge(0, -1, i, j, *maxima);
359 cannyTraceEdge(0, 1, i, j, *maxima);
360 cannyTraceEdge(-1, 1, i, j, *maxima);
361 cannyTraceEdge(1, -1, i, j, *maxima);
366 for (std::size_t i = 0; i < input_->size(); ++i) {
367 if ((*maxima)[i].intensity == std::numeric_limits<float>::max())
368 output[i].magnitude = 255;
370 output[i].magnitude = 0;
380 float tHigh = hysteresis_threshold_high_;
381 float tLow = hysteresis_threshold_low_;
382 const int height = input_x.
height;
383 const int width = input_x.
width;
385 output.
resize(height * width);
387 output.
width = width;
391 kernel_.setKernelSize(3);
392 kernel_.setKernelSigma(1.0);
394 kernel_.fetchKernel(*gaussian_kernel);
395 convolution_.setKernel(*gaussian_kernel);
398 convolution_.setInputCloud(input_x.
makeShared());
399 convolution_.filter(smoothed_cloud_x);
402 convolution_.setInputCloud(input_y.
makeShared());
403 convolution_.filter(smoothed_cloud_y);
407 sobelMagnitudeDirection(smoothed_cloud_x, smoothed_cloud_y, *edges.get());
410 discretizeAngles(*edges);
413 suppressNonMaxima(*edges, *maxima, tLow);
416 for (
int i = 0; i < height; i++) {
417 for (
int j = 0; j < width; j++) {
418 if ((*maxima)(j, i).intensity < tHigh ||
419 (*maxima)(j, i).intensity == std::numeric_limits<float>::max())
422 (*maxima)(j, i).intensity = std::numeric_limits<float>::max();
425 cannyTraceEdge( 1, 0, i, j, *maxima);
426 cannyTraceEdge(-1, 0, i, j, *maxima);
427 cannyTraceEdge( 1, 1, i, j, *maxima);
428 cannyTraceEdge(-1, -1, i, j, *maxima);
429 cannyTraceEdge( 0, -1, i, j, *maxima);
430 cannyTraceEdge( 0, 1, i, j, *maxima);
431 cannyTraceEdge(-1, 1, i, j, *maxima);
432 cannyTraceEdge( 1, -1, i, j, *maxima);
438 for (
int i = 0; i < height; i++) {
439 for (
int j = 0; j < width; j++) {
440 if ((*maxima)(j, i).intensity == std::numeric_limits<float>::max())
441 output(j, i).magnitude = 255;
443 output(j, i).magnitude = 0;