Skip to Content
OpenCV By Example
book

OpenCV By Example

by Prateek Joshi, David Millán Escrivá, Vinícius G. Mendonça
January 2016
Intermediate to advanced
296 pages
5h 59m
English
Packt Publishing
Content preview from OpenCV By Example

Thickening the shapes

We use an operation called dilation to achieve thickening. This is an operation that makes a shape thicker by adding boundary layers to all the shapes in the image:

Thickening the shapes

Here is the code to do this:

Mat performDilation(Mat inputImage, int dilationElement, int dilationSize) { Mat outputImage; int dilationType; if(dilationElement == 0) dilationType = MORPH_RECT; else if(dilationElement == 1) dilationType = MORPH_CROSS; else if(dilationElement == 2) dilationType = MORPH_ELLIPSE; // Create the structuring element for dilation Mat element = getStructuringElement(dilationType, Size(2*dilationSize + 1, 2*dilationSize + 1), Point(dilationSize, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering OpenCV 4 - Third Edition

Mastering OpenCV 4 - Third Edition

Roy Shilkrot, David Millán Escrivá

Publisher Resources

ISBN: 9781785280948Supplemental Content