Update documentation ( tutorials )

This commit is contained in:
Suleyman TURKMEN
2016-07-18 16:32:05 +03:00
parent 55d0945149
commit bb6f65c199
34 changed files with 369 additions and 1333 deletions
@@ -1,6 +1,6 @@
/**
* @file Sobel_Demo.cpp
* @brief Sample code using Sobel and/orScharr OpenCV functions to make a simple Edge Detector
* @brief Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
* @author OpenCV team
*/
@@ -15,28 +15,31 @@ using namespace cv;
*/
int main( int, char** argv )
{
//![variables]
Mat src, src_gray;
Mat grad;
const char* window_name = "Sobel Demo - Simple Edge Detector";
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
//![variables]
/// Load an image
src = imread( argv[1], IMREAD_COLOR );
//![load]
src = imread( argv[1], IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
//![load]
//![reduce_noise]
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
//![reduce_noise]
/// Convert it to gray
cvtColor( src, src_gray, COLOR_RGB2GRAY );
/// Create window
namedWindow( window_name, WINDOW_AUTOSIZE );
//![convert_to_gray]
cvtColor( src, src_gray, COLOR_BGR2GRAY );
//![convert_to_gray]
//![sobel]
/// Generate grad_x and grad_y
Mat grad_x, grad_y;
Mat abs_grad_x, abs_grad_y;
@@ -44,19 +47,26 @@ int main( int, char** argv )
/// Gradient X
//Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT );
Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
convertScaleAbs( grad_x, abs_grad_x );
/// Gradient Y
//Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
Sobel( src_gray, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT );
convertScaleAbs( grad_y, abs_grad_y );
//![sobel]
//![convert]
convertScaleAbs( grad_x, abs_grad_x );
convertScaleAbs( grad_y, abs_grad_y );
//![convert]
//![blend]
/// Total Gradient (approximate)
addWeighted( abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad );
//![blend]
//![display]
imshow( window_name, grad );
waitKey(0);
//![display]
return 0;
}