0% found this document useful (0 votes)
55 views49 pages

Chapter 2 - Slide

OpenCV is an open source library for computer vision and machine learning. It has interfaces in C++, Python, Java and MATLAB. OpenCV supports image processing, object detection and other algorithms. Numpy is a fundamental package for scientific computing in Python that allows users to work with multi-dimensional arrays and matrices. Matplotlib is a plotting library that produces publication quality 2D plots of arrays. It treats images as RGB while OpenCV treats them as BGR. Both can be used for tasks like image loading, color space conversion, and geometric transformations.

Uploaded by

Ayozzet Wef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views49 pages

Chapter 2 - Slide

OpenCV is an open source library for computer vision and machine learning. It has interfaces in C++, Python, Java and MATLAB. OpenCV supports image processing, object detection and other algorithms. Numpy is a fundamental package for scientific computing in Python that allows users to work with multi-dimensional arrays and matrices. Matplotlib is a plotting library that produces publication quality 2D plots of arrays. It treats images as RGB while OpenCV treats them as BGR. Both can be used for tasks like image loading, color space conversion, and geometric transformations.

Uploaded by

Ayozzet Wef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Python and OpenCV

Chapter 2 : DEC40092 (Computer Vision Programming)


What is OpenCV?
OpenCV

Open source computer vision and machine learning software library.

It has C++, Python, Java and MATLAB interfaces and supports Windows, Linux,
Android and Mac OS
What is Image Processing?

Method to perform some operation on an image, in order to get an enhanced


image or extract some useful information from it
Examples of using image processing (1/4)

Line Follower Robot

….what else?
Examples of using image processing (2/4)

Fruit / Stuff Separator Machine


Examples of using image processing (3/4)

Face Recognition for class attendance


Examples of using image processing (4/4)

QR code and Barcode reader


2.1 Understand Python required
packages and libraries for
OpenCV
Libraries or tools for image processing for
Python (....explore them)

Scikit-image Matplotlib

OpenCV Numpy

Mahotas SimpleCV

SimpleITK Pgmagick

Scipy Pycairo

Pillow / PIL cvlib


What we will learn...
2.1.1 Explain Numpy and SciPy

Numpy - Numerical Python Operation can be perform using Numpy:

https://numpy.org/devdocs/user/quickstart.html a) Mathematical and logical operation arrays

library consisting of multidimensional array b) Fourier transforms and routines for shape
objects and a collection of routines for manipulation
processing of array
c) Operation related to linear algebra and
can be installed by using pip Python package random number generation
installer
What is “array”?

Array Data Structure is a data consisting of


collection of elements (values/variables), each
identified by at least one array index or key (a.k.a
matrix)
Understand this matrix...
Why need Numpy?

Computer can’t understand the colours but


understand the image pixel (matrix as in
three-dimension) which represents RGB colour.
Colour in each pixel (1/4)

B,G,R = 0, 0, 0 means black

B,G,R = 255, 255, 255 means white


Colour in each pixel (2/4)
Colour in each pixel (3/4)
Colour in each pixel (4/4)
Numpy Data Representation
Example of array in picture (1/3)

Stored a picture named logo.jpg in

“C:/Users/pnagaraj/Pictures/opencv”
Example of array in picture (2/3)

View picture as array using


Python script
Example of array in picture (3/3)

Get the shape of pixel in array

The output (663, 1599, 3) defines as (Height.


Width, Colour present RGB)
Numpy
List of some useful Numpy functions
and methods in categories

RGB Colour Codes Chart:


https://www.rapidtables.com/web/col
or/RGB_Color.html
Numpy Conclusion
Numpy is more about classifying any
image into array data structure or
matrix value.

Numpy is depending on colour code in


BGR code but not RGB

Numpy also can manipulate colour


from image
2.1.1 Explain Numpy and SciPy

SciPy - Scientific Python

A collection of open source software for


scientific computing in Python
SciPy
SciPy consists of a collection of
numerical algorithms and
domain-specific toolboxes including
signal processing, optimization,
statistics and much more.

SciPy sub-packages need to be


imported separately, for example:
2.1.2 Explain Matplotlib

Matplotlib - Mathematical Plotting Library

Plotting library for the Python programming


language and its numerical mathematics
extension Numpy.
Example of Matplotlib
Things to remember

Matplotlib produced an exact image as Original IMPORTANT :


(same colour as Original) but OpenCV changed
some colors and opened the images. Example Matplotlib treats the images with RGB but
as below: OpenCV treats the images as BGR colour
(actual: all images are in RGB).
Difference output using simple image open
and Matplotlib plotting

The image is drawn in coordinate existence. The image is drawn exactly as a source.
Example of single colour extraction
Single colour manipulation
Colour(s) manipulation
The goal of the single
color extraction
method is to reduce
the dimensionality of
the color feature
space while gaining..
Plotting using
Matplotlib
Object-oriented
style
Pyplot style
Matplotlib
Conclusion
Maplotlib is more about drawing to
make as output

Maplotlib easily draw by using array


concept

Matplotlib treats images as RGB from


its source
2.1.3 Explain OpenCV

OpenCV - Open-source Computer Vision

An open-source BSD-licensed library that include


several hundreds of computer vision algorithm
Modular structures available
(shared and static)

Core functionality (core) Object Detection (objdetect)

Image processing (imgproc) High-level GUI (highgui)

Video Analysis (video) Video I/O (videoio)

Camera Calibration and 3D Reconstruction Other modules like FLANN and Google test
(calib3d) wrappers, Python bindings and others

2D Features Framework (features2d)


What we will cover are ....

GUI Features

Core Operation

Image Processing
GUI Features

Images Read, write (save) and display

Videos Drawing geometric shapes

Drawing Function
Core Operation

Basic Operation Accessing pixel values and modify them

Arithmetic Operation Arithmetic operation on images


Image Processing

Changing Colorspaces Changing images between colour spaces

Geometric Transformation of Images Images translation, rotation and affine


transformation
Image Thresholding
Convert images to binary images
Smoothing Images
Smoothing and blurring images
Contours
Find different properties of contours
Histograms
Graph or plot about intensity distribution of an
image
BGR ≠ RGB...
Thanks!
Contact me:

BP2
JKE PSAS
019 - 730 7570

[email protected]

You might also like