.2.0+dfsg_contrib_modules_ximgproc_tutorials_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
17 "{i || input image name}"
19 "{o || output image name}"
22 int main(
int argc,
const char** argv )
24 bool printHelp = ( argc == 1 );
25 printHelp = printHelp || ( argc == 2 &&
String(argv[1]) ==
"--help" );
26 printHelp = printHelp || ( argc == 2 &&
String(argv[1]) ==
"-h" );
30 std::cout <<
"\nThis sample demonstrates structured forests for fast edge detection\n"
32 " structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n";
37 if ( !parser.check() )
51 if ( modelFilename.
size() == 0)
56 Mat edges(image.size(), image.type());
62 if ( outFilename.size() == 0 )
69 imwrite(outFilename, 255*edges);
Explanation
- Load source color image
{
printf("Cannot read image file: %s\n", inFilename.c_str());
return -1;
}
- Convert source image to [0;1] range
- Run main algorithm
pDollar->detectEdges(image, edges);
- Show results
if ( outFilename == "" )
{
}
else
Literature
For more information, refer to the following papers : [Dollar2013] [Lim2013]