Skip to content

Commit 6c6900a

Browse files
committed
Merge pull request opencv#9424 from Cartucho:update_imgproc_tutorials
2 parents 21bd834 + 9a2317e commit 6c6900a

File tree

50 files changed

+3311
-899
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3311
-899
lines changed

doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.markdown

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
Smoothing Images {#tutorial_gausian_median_blur_bilateral_filter}
22
================
33

4+
@next_tutorial{tutorial_erosion_dilatation}
5+
46
Goal
57
----
68

79
In this tutorial you will learn how to apply diverse linear filters to smooth images using OpenCV
810
functions such as:
911

10-
- @ref cv::blur
11-
- @ref cv::GaussianBlur
12-
- @ref cv::medianBlur
13-
- @ref cv::bilateralFilter
12+
- **blur()**
13+
- **GaussianBlur()**
14+
- **medianBlur()**
15+
- **bilateralFilter()**
1416

1517
Theory
1618
------
@@ -92,38 +94,65 @@ Code
9294
- Loads an image
9395
- Applies 4 different kinds of filters (explained in Theory) and show the filtered images
9496
sequentially
97+
98+
@add_toggle_cpp
99+
- **Downloadable code**: Click
100+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp)
101+
102+
- **Code at glance:**
103+
@include samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp
104+
@end_toggle
105+
106+
@add_toggle_java
95107
- **Downloadable code**: Click
96-
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Smoothing.cpp)
108+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java)
109+
110+
- **Code at glance:**
111+
@include samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java
112+
@end_toggle
113+
114+
@add_toggle_python
115+
- **Downloadable code**: Click
116+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/python/tutorial_code/imgProc/Smoothing/smoothing.py)
117+
97118
- **Code at glance:**
98-
@include samples/cpp/tutorial_code/ImgProc/Smoothing.cpp
119+
@include samples/python/tutorial_code/imgProc/Smoothing/smoothing.py
120+
@end_toggle
99121

100122
Explanation
101123
-----------
102124

103-
-# Let's check the OpenCV functions that involve only the smoothing procedure, since the rest is
104-
already known by now.
105-
-# **Normalized Block Filter:**
125+
Let's check the OpenCV functions that involve only the smoothing procedure, since the rest is
126+
already known by now.
106127

107-
OpenCV offers the function @ref cv::blur to perform smoothing with this filter.
108-
@snippet cpp/tutorial_code/ImgProc/Smoothing.cpp blur
128+
#### Normalized Block Filter:
109129

130+
- OpenCV offers the function **blur()** to perform smoothing with this filter.
110131
We specify 4 arguments (more details, check the Reference):
111-
112132
- *src*: Source image
113133
- *dst*: Destination image
114-
- *Size( w,h )*: Defines the size of the kernel to be used ( of width *w* pixels and height
134+
- *Size( w, h )*: Defines the size of the kernel to be used ( of width *w* pixels and height
115135
*h* pixels)
116136
- *Point(-1, -1)*: Indicates where the anchor point (the pixel evaluated) is located with
117137
respect to the neighborhood. If there is a negative value, then the center of the kernel is
118138
considered the anchor point.
119139

120-
-# **Gaussian Filter:**
140+
@add_toggle_cpp
141+
@snippet cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp blur
142+
@end_toggle
121143

122-
It is performed by the function @ref cv::GaussianBlur :
123-
@snippet cpp/tutorial_code/ImgProc/Smoothing.cpp gaussianblur
144+
@add_toggle_java
145+
@snippet samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java blur
146+
@end_toggle
124147

125-
Here we use 4 arguments (more details, check the OpenCV reference):
148+
@add_toggle_python
149+
@snippet samples/python/tutorial_code/imgProc/Smoothing/smoothing.py blur
150+
@end_toggle
151+
152+
#### Gaussian Filter:
126153

154+
- It is performed by the function **GaussianBlur()** :
155+
Here we use 4 arguments (more details, check the OpenCV reference):
127156
- *src*: Source image
128157
- *dst*: Destination image
129158
- *Size(w, h)*: The size of the kernel to be used (the neighbors to be considered). \f$w\f$ and
@@ -134,35 +163,65 @@ Explanation
134163
- \f$\sigma_{y}\f$: The standard deviation in y. Writing \f$0\f$ implies that \f$\sigma_{y}\f$ is
135164
calculated using kernel size.
136165

137-
-# **Median Filter:**
166+
@add_toggle_cpp
167+
@snippet cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp gaussianblur
168+
@end_toggle
138169

139-
This filter is provided by the @ref cv::medianBlur function:
140-
@snippet cpp/tutorial_code/ImgProc/Smoothing.cpp medianblur
170+
@add_toggle_java
171+
@snippet samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java gaussianblur
172+
@end_toggle
141173

142-
We use three arguments:
174+
@add_toggle_python
175+
@snippet samples/python/tutorial_code/imgProc/Smoothing/smoothing.py gaussianblur
176+
@end_toggle
177+
178+
#### Median Filter:
143179

180+
- This filter is provided by the **medianBlur()** function:
181+
We use three arguments:
144182
- *src*: Source image
145183
- *dst*: Destination image, must be the same type as *src*
146184
- *i*: Size of the kernel (only one because we use a square window). Must be odd.
147185

148-
-# **Bilateral Filter**
186+
@add_toggle_cpp
187+
@snippet cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp medianblur
188+
@end_toggle
149189

150-
Provided by OpenCV function @ref cv::bilateralFilter
151-
@snippet cpp/tutorial_code/ImgProc/Smoothing.cpp bilateralfilter
190+
@add_toggle_java
191+
@snippet samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java medianblur
192+
@end_toggle
152193

153-
We use 5 arguments:
194+
@add_toggle_python
195+
@snippet samples/python/tutorial_code/imgProc/Smoothing/smoothing.py medianblur
196+
@end_toggle
197+
198+
#### Bilateral Filter
154199

200+
- Provided by OpenCV function **bilateralFilter()**
201+
We use 5 arguments:
155202
- *src*: Source image
156203
- *dst*: Destination image
157204
- *d*: The diameter of each pixel neighborhood.
158205
- \f$\sigma_{Color}\f$: Standard deviation in the color space.
159206
- \f$\sigma_{Space}\f$: Standard deviation in the coordinate space (in pixel terms)
160207

208+
@add_toggle_cpp
209+
@snippet cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp bilateralfilter
210+
@end_toggle
211+
212+
@add_toggle_java
213+
@snippet samples/java/tutorial_code/ImgProc/Smoothing/Smoothing.java bilateralfilter
214+
@end_toggle
215+
216+
@add_toggle_python
217+
@snippet samples/python/tutorial_code/imgProc/Smoothing/smoothing.py bilateralfilter
218+
@end_toggle
219+
161220
Results
162221
-------
163222

164-
- The code opens an image (in this case *lena.jpg*) and display it under the effects of the 4
165-
filters explained.
223+
- The code opens an image (in this case [lena.jpg](https://raw.githubusercontent.com/opencv/opencv/master/samples/data/lena.jpg))
224+
and display it under the effects of the 4 filters explained.
166225
- Here is a snapshot of the image smoothed using *medianBlur*:
167226

168227
![](images/Smoothing_Tutorial_Result_Median_Filter.jpg)

doc/tutorials/imgproc/hitOrMiss/hitOrMiss.markdown

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
Hit-or-Miss {#tutorial_hitOrMiss}
22
=================================
33

4+
@prev_tutorial{tutorial_opening_closing_hats}
5+
@next_tutorial{tutorial_morph_lines_detection}
6+
47
Goal
58
----
69

710
In this tutorial you will learn how to find a given configuration or pattern in a binary image by using the Hit-or-Miss transform (also known as Hit-and-Miss transform).
811
This transform is also the basis of more advanced morphological operations such as thinning or pruning.
912

10-
We will use the OpenCV function @ref cv::morphologyEx.
11-
12-
13+
We will use the OpenCV function **morphologyEx()** .
1314

1415
Hit-or-Miss theory
1516
-------------------
1617

1718
Morphological operators process images based on their shape. These operators apply one or more *structuring elements* to an input image to obtain the output image.
1819
The two basic morphological operations are the *erosion* and the *dilation*. The combination of these two operations generate advanced morphological transformations such as *opening*, *closing*, or *top-hat* transform.
19-
To know more about these and other basic morphological operations refer to previous tutorials @ref tutorial_erosion_dilatation "here" and @ref tutorial_opening_closing_hats "here".
20+
To know more about these and other basic morphological operations refer to previous tutorials (@ref tutorial_erosion_dilatation "Eroding and Dilating") and (@ref tutorial_opening_closing_hats "More Morphology Transformations").
2021

2122
The Hit-or-Miss transformation is useful to find patterns in binary images. In particular, it finds those pixels whose neighbourhood matches the shape of a first structuring element \f$B_1\f$
2223
while not matching the shape of a second structuring element \f$B_2\f$ at the same time. Mathematically, the operation applied to an image \f$A\f$ can be expressed as follows:
@@ -43,11 +44,27 @@ You can see that the pattern is found in just one location within the image.
4344
Code
4445
----
4546

46-
The code corresponding to the previous example is shown below. You can also download it from
47-
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/HitMiss.cpp)
48-
@include samples/cpp/tutorial_code/ImgProc/HitMiss.cpp
47+
The code corresponding to the previous example is shown below.
48+
49+
@add_toggle_cpp
50+
You can also download it from
51+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp)
52+
@include samples/cpp/tutorial_code/ImgProc/HitMiss/HitMiss.cpp
53+
@end_toggle
54+
55+
@add_toggle_java
56+
You can also download it from
57+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/java/tutorial_code/ImgProc/HitMiss/HitMiss.java)
58+
@include samples/java/tutorial_code/ImgProc/HitMiss/HitMiss.java
59+
@end_toggle
60+
61+
@add_toggle_python
62+
You can also download it from
63+
[here](https://raw.githubusercontent.com/opencv/opencv/master/samples/python/tutorial_code/imgProc/HitMiss/hit_miss.py)
64+
@include samples/python/tutorial_code/imgProc/HitMiss/hit_miss.py
65+
@end_toggle
4966

50-
As you can see, it is as simple as using the function @ref cv::morphologyEx with the operation type @ref cv::MORPH_HITMISS and the chosen kernel.
67+
As you can see, it is as simple as using the function **morphologyEx()** with the operation type **MORPH_HITMISS** and the chosen kernel.
5168

5269
Other examples
5370
--------------

0 commit comments

Comments
 (0)