1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
Structured forests for fast edge detection {#tutorial_ximgproc_prediction}
==========================================
Introduction
------------
In this tutorial you will learn how to use structured forests for the purpose of edge detection in
an image.
Examples
--------












@note binarization techniques like Canny edge detector are applicable to edges produced by both
algorithms (Sobel and StructuredEdgeDetection::detectEdges).
Source Code
-----------
@includelineno ximgproc/samples/structured_edge_detection.cpp
Explanation
-----------
-# **Load source color image**
@code{.cpp}
cv::Mat image = cv::imread(inFilename, 1);
if ( image.empty() )
{
printf("Cannot read image file: %s\n", inFilename.c_str());
return -1;
}
@endcode
-# **Convert source image to [0;1] range**
@code{.cpp}
image.convertTo(image, cv::DataType<float>::type, 1/255.0);
@endcode
-# **Run main algorithm**
@code{.cpp}
cv::Mat edges(image.size(), image.type());
cv::Ptr<StructuredEdgeDetection> pDollar =
cv::createStructuredEdgeDetection(modelFilename);
pDollar->detectEdges(image, edges);
@endcode
-# **Show results**
@code{.cpp}
if ( outFilename == "" )
{
cv::namedWindow("edges", 1);
cv::imshow("edges", edges);
cv::waitKey(0);
}
else
cv::imwrite(outFilename, 255*edges);
@endcode
Literature
----------
For more information, refer to the following papers : @cite Dollar2013 @cite Lim2013
|