本文整理汇总了C++中Gaussian::smoothImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Gaussian::smoothImage方法的具体用法?C++ Gaussian::smoothImage怎么用?C++ Gaussian::smoothImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaussian
的用法示例。
在下文中一共展示了Gaussian::smoothImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunCannyTest
void Test::RunCannyTest(const RGBImage* in) {
Gaussian smoother;
Sobel sobel;
Canny canny;
StudentPreProcessing converter;
double sigma = 1.6;
int kernelSize = 5;
// Convert RGB to Intensity
IntensityImage* grey = ImageFactory::newIntensityImage(in->getWidth(), in->getHeight());
grey = converter.stepToIntensityImage(*in);
BaseTimer timer;
int total = 0;
for (int i = 0; i < 10; ++i) {
timer.start();
/* Start of Canny */
// 1. Smooth Intensity with Gaussian
IntensityImage* gaussian = ImageFactory::newIntensityImage(in->getWidth() - kernelSize, in->getHeight() - kernelSize);
smoother.smoothImage(grey, gaussian, sigma, kernelSize);
// 2. Find edges with Sobel (convolve X and Y separately for Canny)
int sobelKernelSize = 3;
IntensityImage* sobelX = ImageFactory::newIntensityImage(gaussian->getWidth() - sobelKernelSize, gaussian->getHeight() - sobelKernelSize);
IntensityImage* sobelY = ImageFactory::newIntensityImage(gaussian->getWidth() - sobelKernelSize, gaussian->getHeight() - sobelKernelSize);
sobel.filterXY(gaussian, sobelX, sobelY);
// 3. Apply non-maximum suppresion
IntensityImage* nonMaxSuppression = ImageFactory::newIntensityImage(sobelX->getWidth(), sobelX->getHeight());
canny.nonMaximumSurpression(sobelX, sobelY, nonMaxSuppression);
// 4. Apply hysteresis threshold
IntensityImage* hysteresisThreshold = ImageFactory::newIntensityImage(sobelX->getWidth(), sobelX->getHeight());
canny.threshold(nonMaxSuppression, hysteresisThreshold, 60, 70);
timer.stop();
std::cout << timer.elapsedMilliSeconds() << " ms" << std::endl;
total += timer.elapsedMilliSeconds();
timer.reset();
if (i == 9)
ImageIO::saveIntensityImage(*hysteresisThreshold, ImageIO::getDebugFileName("Canny.png"));
}
std::cout << "Average time per Canny edge detection: " << (total / 10) << " ms" << std::endl;
std::cout << "Press the X in the console window to exit program" << std::endl;
}