Skip to Content
Learning OpenCV 4 Computer Vision with Python 3 - Third Edition
book

Learning OpenCV 4 Computer Vision with Python 3 - Third Edition

by Joseph Howse, Joe Minichino
February 2020
Intermediate to advanced
372 pages
9h 26m
English
Packt Publishing
Content preview from Learning OpenCV 4 Computer Vision with Python 3 - Third Edition

Masking a copy operation

The rects module is implemented in rects.py. We already saw a call to the rects.swapRects function in the previous section. However, before we consider the implementation of swapRects, we first need to a more basic copyRect function.

As far back as Chapter 2, Handling Files, Cameras, and GUIs, we learned how to copy data from one rectangular region of interest (ROI) to another using NumPy's slicing syntax. Outside the ROIs, the source and destination images were unaffected. Now, we want to apply further limits to this copy operation. We want to use a given mask that has the same dimensions as the source rectangle.

We shall copy only those pixels in the source rectangle where the mask's value is not zero. Other pixels ...

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

Building Computer Vision Projects with OpenCV 4 and C++

Building Computer Vision Projects with OpenCV 4 and C++

David Millan Escriva, Prateek Joshi, Vinicius G. Mendonca, Roy Shilkrot

Publisher Resources

ISBN: 9781789531619Supplemental Content