* Use the function :corner_harris:`cornerHarris <>` to detect corners using the Harris-Stephens method.
Theory
======
What is a feature?
-------------------
.. container:: enumeratevisibleitemswithsquare
* In computer vision, usually we need to find matching points between different frames of an environment. Why? If we know how two images relate to each other, we can use *both* images to extract information of them.
* When we say **matching points** we are referring, in a general sense, to *characteristics* in the scene that we can recognize easily. We call these characteristics **features**.
* **So, what characteristics should a feature have?**
* It must be *uniquely recognizable*
Types of Image Features
------------------------
To mention a few:
.. container:: enumeratevisibleitemswithsquare
* Edges
* Corner (also known as interest points)
* Blobs (also known as regions of interest )
In this tutorial we will study the *corner* features, specifically.
This tutorial code's is shown lines below. You can also download it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/Image_Processing/Morphology_1.cpp>`_
This tutorial code's is shown lines below. You can also download it from `here <https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp>`_
.. code-block:: cpp
...
...
@@ -175,16 +175,16 @@ Explanation
#. Most of the stuff shown is known by you (if you have any doubt, please refer to the tutorials in previous sections). Let's check the general structure of the program:
* Load an image (can be RGB or grayscale)
.. container:: enumeratevisibleitemswithsquare
* Create two windows (one for dilation output, the other for erosion)
* Load an image (can be RGB or grayscale)
* Create two windows (one for dilation output, the other for erosion)
* Create a set of 02 Trackbars for each operation:
* Create a set of 02 Trackbars for each operation:
* The first trackbar "Element" returns either **erosion_elem** or **dilation_elem**
* The second trackbar "Kernel size" return **erosion_size** or **dilation_size** for the corresponding operation.
* The first trackbar "Element" returns either **erosion_elem** or **dilation_elem**
* The second trackbar "Kernel size" return **erosion_size** or **dilation_size** for the corresponding operation.
* Every time we move any slider, the user's function **Erosion** or **Dilation** will be called and it will update the output image based on the current trackbar values.
* Every time we move any slider, the user's function **Erosion** or **Dilation** will be called and it will update the output image based on the current trackbar values.
Let's analyze these two functions:
...
...
@@ -220,13 +220,15 @@ Explanation
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
Point( erosion_size, erosion_size ) );
We can choose any of three shapes for our kernel:
We can choose any of three shapes for our kernel:
.. container:: enumeratevisibleitemswithsquare
* Rectangular box: MORPH_RECT
* Cross: MORPH_CROSS
* Ellipse: MORPH_ELLIPSE
+ Rectangular box: MORPH_RECT
+ Cross: MORPH_CROSS
+ Ellipse: MORPH_ELLIPSE
Then, we just have to specify the size of our kernel and the *anchor point*. If not specified, it is assumed to be in the center.
Then, we just have to specify the size of our kernel and the *anchor point*. If not specified, it is assumed to be in the center.
* That is all. We are ready to perform the erosion of our image.
* Use the OpenCV functions :pyr_up:`pyrUp <>` and :pyr_down:`pyrDown <>` to downsample or upsample a given image.
.. container:: enumeratevisibleitemswithsquare
* Use the OpenCV functions :pyr_up:`pyrUp <>` and :pyr_down:`pyrDown <>` to downsample or upsample a given image.
Theory
=======
...
...
@@ -16,25 +18,30 @@ Theory
.. note::
The explanation below belongs to the book **Learning OpenCV** by Bradski and Kaehler.
* Usually we need to convert an image to a size different than its original. For this, there are two possible options:
.. container:: enumeratevisibleitemswithsquare
* Usually we need to convert an image to a size different than its original. For this, there are two possible options:
* *Upsize* the image (zoom in) or
* *Downsize* it (zoom out).
#. *Upsize* the image (zoom in) or
#. *Downsize* it (zoom out).
* Although there is a *geometric transformation* function in OpenCV that -literally- resize an image (:resize:`resize <>`, which we will show in a future tutorial), in this section we analyze first the use of **Image Pyramids**, which are widely applied in a huge range of vision applications.
* Although there is a *geometric transformation* function in OpenCV that -literally- resize an image (:resize:`resize <>`, which we will show in a future tutorial), in this section we analyze first the use of **Image Pyramids**, which are widely applied in a huge range of vision applications.
Image Pyramid
--------------
* An image pyramid is a collection of images - all arising from a single original image - that are successively downsampled until some desired stopping point is reached.
.. container:: enumeratevisibleitemswithsquare
* An image pyramid is a collection of images - all arising from a single original image - that are successively downsampled until some desired stopping point is reached.
* There are two common kinds of image pyramids:
* There are two common kinds of image pyramids:
* **Gaussian pyramid:** Used to downsample images
* **Gaussian pyramid:** Used to downsample images
* **Laplacian pyramid:** Used to reconstruct an upsampled image from an image lower in the pyramid (with less resolution)
* **Laplacian pyramid:** Used to reconstruct an upsampled image from an image lower in the pyramid (with less resolution)
* In this tutorial we'll use the *Gaussian pyramid*.
* In this tutorial we'll use the *Gaussian pyramid*.