Skip to content

Commit d0c4e65

Browse files
author
Ernest
committed
Fix style.
1 parent 62ad28a commit d0c4e65

File tree

35 files changed

+2284
-2256
lines changed

35 files changed

+2284
-2256
lines changed

code/artificial_intelligence/src/image_processing/canny/canny.cpp

Lines changed: 190 additions & 193 deletions
Large diffs are not rendered by default.

code/artificial_intelligence/src/image_processing/canny/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ int main()
1717
{
1818
std::string filePath = "lena.jpg"; //Filepath of input image
1919
canny cny(filePath);
20-
20+
2121
return 0;
2222
}
23-

code/artificial_intelligence/src/image_processing/erode_dilate/main.cpp

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,72 +21,77 @@ void Dilation( int, void* );
2121
/** @function main */
2222
int main( int argc, char** argv )
2323
{
24-
/// Load an image
25-
src = cv::imread( argv[1] );
26-
27-
if( !src.data )
28-
{ return -1; }
29-
30-
/// Create windows
31-
cv::namedWindow( "Erosion Demo", CV_WINDOW_AUTOSIZE );
32-
cv::namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE );
33-
cvMoveWindow( "Dilation Demo", src.cols, 0 );
34-
35-
/// Create Erosion Trackbar
36-
cv::createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
37-
&erosion_elem, max_elem,
38-
Erosion );
39-
40-
cv::createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
41-
&erosion_size, max_kernel_size,
42-
Erosion );
43-
44-
/// Create Dilation Trackbar
45-
cv::createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
46-
&dilation_elem, max_elem,
47-
Dilation );
48-
49-
cv::createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
50-
&dilation_size, max_kernel_size,
51-
Dilation );
52-
53-
/// Default start
54-
Erosion( 0, 0 );
55-
Dilation( 0, 0 );
56-
57-
cv::waitKey(0);
58-
return 0;
24+
/// Load an image
25+
src = cv::imread( argv[1] );
26+
27+
if (!src.data)
28+
return -1;
29+
/// Create windows
30+
cv::namedWindow( "Erosion Demo", CV_WINDOW_AUTOSIZE );
31+
cv::namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE );
32+
cvMoveWindow( "Dilation Demo", src.cols, 0 );
33+
34+
/// Create Erosion Trackbar
35+
cv::createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
36+
&erosion_elem, max_elem,
37+
Erosion );
38+
39+
cv::createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
40+
&erosion_size, max_kernel_size,
41+
Erosion );
42+
43+
/// Create Dilation Trackbar
44+
cv::createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
45+
&dilation_elem, max_elem,
46+
Dilation );
47+
48+
cv::createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
49+
&dilation_size, max_kernel_size,
50+
Dilation );
51+
52+
/// Default start
53+
Erosion( 0, 0 );
54+
Dilation( 0, 0 );
55+
56+
cv::waitKey(0);
57+
return 0;
5958
}
6059

6160
/** @function Erosion */
6261
void Erosion( int, void* )
6362
{
64-
int erosion_type;
65-
if( erosion_elem == 0 ){ erosion_type = cv::MORPH_RECT; }
66-
else if( erosion_elem == 1 ){ erosion_type = cv::MORPH_CROSS; }
67-
else if( erosion_elem == 2) { erosion_type = cv::MORPH_ELLIPSE; }
68-
69-
cv::Mat element = cv::getStructuringElement( erosion_type,
70-
cv::Size( 2*erosion_size + 1, 2*erosion_size+1 ),
71-
cv::Point( erosion_size, erosion_size ) );
72-
73-
/// Apply the erosion operation
74-
cv::erode( src, erosion_dst, element );
75-
cv::imshow( "Erosion Demo", erosion_dst );
63+
int erosion_type;
64+
if (erosion_elem == 0)
65+
erosion_type = cv::MORPH_RECT;
66+
else if (erosion_elem == 1)
67+
erosion_type = cv::MORPH_CROSS;
68+
else if (erosion_elem == 2)
69+
erosion_type = cv::MORPH_ELLIPSE;
70+
cv::Mat element = cv::getStructuringElement( erosion_type,
71+
cv::Size( 2 * erosion_size + 1,
72+
2 * erosion_size + 1 ),
73+
cv::Point( erosion_size, erosion_size ) );
74+
75+
/// Apply the erosion operation
76+
cv::erode( src, erosion_dst, element );
77+
cv::imshow( "Erosion Demo", erosion_dst );
7678
}
7779

7880
/** @function Dilation */
7981
void Dilation( int, void* )
8082
{
81-
int dilation_type;
82-
if( dilation_elem == 0 ){ dilation_type = cv::MORPH_RECT; }
83-
else if( dilation_elem == 1 ){ dilation_type = cv::MORPH_CROSS; }
84-
else if( dilation_elem == 2) { dilation_type = cv::MORPH_ELLIPSE; }
85-
86-
cv::Mat element = cv::getStructuringElement( dilation_type,
87-
cv::Size( 2*dilation_size + 1, 2*dilation_size+1 ),
88-
cv::Point( dilation_size, dilation_size ) );
89-
/// Apply the dilation operation
90-
cv::dilate( src, dilation_dst, element );
91-
cv::imshow( "Dilation Demo", dilation_dst );
83+
int dilation_type;
84+
if (dilation_elem == 0)
85+
dilation_type = cv::MORPH_RECT;
86+
else if (dilation_elem == 1)
87+
dilation_type = cv::MORPH_CROSS;
88+
else if (dilation_elem == 2)
89+
dilation_type = cv::MORPH_ELLIPSE;
90+
cv::Mat element = cv::getStructuringElement( dilation_type,
91+
cv::Size( 2 * dilation_size + 1,
92+
2 * dilation_size + 1 ),
93+
cv::Point( dilation_size, dilation_size ) );
94+
/// Apply the dilation operation
95+
cv::dilate( src, dilation_dst, element );
96+
cv::imshow( "Dilation Demo", dilation_dst );
9297
}

0 commit comments

Comments
 (0)