Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenCV Computer Vision Application Programming Cookbook Second Edition
  • Toc
  • feedback
OpenCV Computer Vision Application Programming Cookbook Second Edition

OpenCV Computer Vision Application Programming Cookbook Second Edition

By : Robert Laganiere
3.7 (3)
close
OpenCV Computer Vision Application Programming Cookbook Second Edition

OpenCV Computer Vision Application Programming Cookbook Second Edition

3.7 (3)
By: Robert Laganiere

Overview of this book

OpenCV 3 Computer Vision Application Programming Cookbook is appropriate for novice C++ programmers who want to learn how to use the OpenCV library to build computer vision applications. It is also suitable for professional software developers wishing to be introduced to the concepts of computer vision programming. It can also be used as a companion book in a university-level computer vision courses. It constitutes an excellent reference for graduate students and researchers in image processing and computer vision.
Table of Contents (13 chapters)
close
12
Index

Detecting edges and corners using morphological filters


Morphological filters can also be used to detect specific features in an image. In this recipe, we will learn how to detect contours and corners in a gray-level image.

Getting ready

In this recipe, the following image will be used:

How to do it...

The edges of an image can be detected by using the appropriate filter of the cv::morphologyEx function. Refer to the following code:

// Get the gradient image using a 3x3 structuring element
cv::Mat result;
cv::morphologyEx(image,result,
                         cv::MORPH_GRADIENT,cv::Mat());

// Apply threshold to obtain a binary image
int threshold= 40;
cv::threshold(result, result, 
                    threshold, 255, cv::THRESH_BINARY);

The following image is obtained as the result:

In order to detect corners using morphology, we now define a class named MorphoFeatures as follows:

class MorphoFeatures {

  private:

     // threshold to produce binary image
    int threshold;
    // structuring...
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete