Sie sind auf Seite 1von 43

C H A P T E R 3.

Fundamentals of
Computer Vision
CHAPTER OUTLINE
INTRODUCTION TO COMPUTER VISION
DIGITAL IMAGE ACQUISITION
FILTERING
DETECTION AND SEGMENTATION
FEATURE EXTRACTION
HIGH-LEVEL PROCESSING AND DECISION MAKING
COMPUTER VISION SOFTWARE PACKAGE
Chapter Objectives
At the end of the chapter, the
student should be able to:
understand the basic concepts of
computer vision;
write computer vision algorithms;
apply computer vision techniques
in solving engineering problems;
and
familiarize with computer vision
software package.

2
I. INTRODUCTION TO COMPUTER VISION

Human Vision
Human vision is
composed of seeing
and perceiving.
Thru the cones and
rods of the eye, image
data is transmitted to
the visual cortex of
the brain thru the optic
chasm at a rate of at
least 10 mbps for
interpretation.
I. INTRODUCTION TO COMPUTER VISION

What is Computer Vision?


Computer Vision (CV) is the study (science) of
vision and the possible design (technology) of
the softwareand to a lesser extent with what
goes into an integrated vision system.
The purpose of CV is to apply computers and
vision systems for acquisition, processing, analysis
and understanding of real world images to make
decisions.
I. INTRODUCTION TO COMPUTER VISION

Computer Vision vs Machine Vision


Machine Vision (MV) meant
the study not only of the
software but also of the
hardware environment and of
the image acquisition
techniques needed for real
applications.
In a sense, MV differs with CV
by adding engineering solution
and design techniques such as
optical, lighting and robotic
systems.
I. INTRODUCTION TO COMPUTER VISION

Actual Computer Vision Applications


Facebook face tagging technology

Milled rice quality assessment

Character and pattern recognition


I. INTRODUCTION TO COMPUTER VISION

Applications of Computer Vision


1. Recognition. The classical
problem in computer vision,
image processing, and
machine vision is that of
determining whether or not
the image data contains some
specific object, feature, or
activity.
I. INTRODUCTION TO COMPUTER VISION

Applications of Computer Vision (cont.)

2. Motion Analysis. An image sequence is processed


to produce an estimate, using vector dynamics, of
the velocity either at each points in the image
I. INTRODUCTION TO COMPUTER VISION

Applications of Computer Vision (cont.)

3. Scene Construction. Given a multi-view projection


or a video of an image, scene reconstruction aims
at computing a 3D model of the scene.
I. INTRODUCTION TO COMPUTER VISION

Applications of Computer Vision (cont.)

4. Image Restoration. The aim of image restoration is


the removal of noise (sensor noise, motion blur, etc.)
from images.
I. INTRODUCTION TO COMPUTER VISION

Fundamental Procedures
1. Digital Image Acquisition using one or multiple image
capturing devices.
2. Image Filtering using noise reduction and image
enhancement.
3. Detection/Segmentation to limit the area for analysis.
4. Feature Extraction by detecting lines, edges and
borders.
5. High-level processing which involves object
recognition.
6. Decision Making based on the gathered data.
II. DIGITAL IMAGE ACQUISITION

What is a digital image?


A digital image is a numeric
representation of a 2D visual
information.
The term generally applies to
raster images which are often
called bitmaps.
A bitmap is an uncompressed
image file format used to store
digital image data on a
rectangular coordinate system.
II. DIGITAL IMAGE ACQUISITION

Digital Image Resolution

[Digital] Image resolution is the density of pixels in


an image.
The higher the resolution, the more information the
image contains and the longer it would take to
analyze the image.
II. DIGITAL IMAGE ACQUISITION

Types of Digital Image


1. Black and White (Grayscale) Images
made up of pixels each of which holds a single
number corresponding to the gray level of the image
at a particular location.
These gray levels span the full range from black to
white in a series of very fine steps, normally 256
different grays and occupies 8 bits of memory.
II. DIGITAL IMAGE ACQUISITION

Types of Digital Image (cont.)


1. Color Images
made up of pixels each of which
holds three numbers corresponding
to the red, green, and blue levels
of the image at a particular
location.
Any color can be created by mixing
the correct amounts of red, green,
and blue light.
At 256 levels for each primary,
each color pixel can be stored in
24 bits of memory corresponding to
16.7 million different possible
colors.
II. DIGITAL IMAGE ACQUISITION

The process of creating a


digital image of a
physical scene is called
digital imaging or
digital image
acquisition.
Digital imaging is done
thru the use of a digital
camera or similar device
such as a flatbed scanner.
II. DIGITAL IMAGE ACQUISITION

The Bitmap Class


The bitmap class is the pixel data for a
graphics image and its attributes.
To declare a bitmap object, use the following
syntax:
Dim <name>>As New Bitmap(<digital image directory>)

To put a bitmap image into a picturebox, use


the following:
PictureBox.Image = <bitmap object>
II. DIGITAL IMAGE ACQUISITION

The Bitmap Class (cont.)


A bitmap
object has
the
following
available
attributes
on the
right.
II. DIGITAL IMAGE ACQUISITION

Obtaining Image Data of a Digital Image


In VB, the color of a specific pixel in a bitmap
object can be obtained using the
Bitmap.GetPixel method.
the following syntax returns a Color object
value:
<bitmap>.GetPixel (<X-coordinate>,<Y-coordinate>)

To return Red, Green, or Blue values, append


.R, .G or .B as shown below:
intRedColor = bm.GetPixel(intXCounter, intYCounter).R
II. DIGITAL IMAGE ACQUISITION

Obtaining Image Data of a Digital Image (cont.)


Being a bitmap, a pixel color data is indexed by
two coordinates; and thus, are stored in a two-
dimensional array as shown:
Dim bm As New Bitmap(OpenFileDialog1.FileName)
PicLoad.Image = bm

intHeight = bm.Height
intWidth = bm.Width

ReDim RawImageColorRed(intWidth - 1, intHeight - 1)


ReDim RawImageColorGreen(intWidth - 1, intHeight - 1)
ReDim RawImageColorBlue(intWidth - 1, intHeight - 1)

For intXCounter As Integer = 0 To intWidth - 1


For intYCounter As Integer = 0 To intHeight - 1
RawImageColorRed(intXCounter, intYCounter) = bm.GetPixel(intXCounter, intYCounter).R
RawImageColorGreen(intXCounter, intYCounter) = bm.GetPixel(intXCounter, intYCounter).G
RawImageColorBlue(intXCounter, intYCounter) = bm.GetPixel(intXCounter, intYCounter).B
Next
Next
III. IMAGE FILTERING

Image filtering is a method


of altering a digital image
so that it can be easily
analyzed.
There are three common
basic image filtering
methods: (1) image
smoothing, (2) increasing
the contrast of a raw
image, (3) removing
bounding pixels.
III. IMAGE FILTERING

Types of Image Filtering


1. Image Smoothing
Simplest thing: replace
each pixel by the
average of its
neighbors.
This assumes that
neighboring pixels are
similar, and the noise to
be independent from
pixel to pixel.
III. IMAGE FILTERING

Types of Image Filtering (cont.)


2. Increasing Contrast
Increasing the color levels of a specific range
of colors by a certain degree.
III. IMAGE FILTERING

Types of Image Filtering (cont.)


3. Noise Reduction
Noise reduction is the
elimination of signal
components with high spatial
frequencies.
If the number of pixels within
an object is below the normal
amount, the group of pixels is
considered as a noise and is
disregarded during analysis.
IV. DETECTION/SEGMENTATION

SEGMENTATION
Segmentation is the
determination of the limits of
objects appearing in digital
images.
Thresholding is an approximate
method of segmentation by
separating the dark and light
regions of an image; i.e.,
identifying dark objects on a
light background (or vice versa)
IV. DETECTION/SEGMENTATION

Threshold Value
Threshold value is the color
value which separates the desired
object from the all objects in the
image.
It can be expressed in RGB,
hexadecimal value or any color in
the specific color space.
Decision structures (mostly if-then)
nested with repetion structures
(mostly for-next) are used To
perform image thresholding.
IV. DETECTION/SEGMENTATION

Example:
The program on
the right is a basic
image thresholding
software written in
Visual BASIC 2010.
IV. DETECTION/SEGMENTATION

Example (cont.):
IV. DETECTION/SEGMENTATION

Binary Image
In threholding, Binary images,
which use only a single bit (on or
off) to represent each pixel, are
used to represent the coordinates
of desired and undesired object
pixel.
Since a bit can only exist in two
states, every pixel in a binary
image must be one of two colors,
usually black and white.
IV. DETECTION/SEGMENTATION

Binary Image (cont.)


A binary image can be generated by
redrawing the image.
Image redrawing can be achieved using the
Form.Paint event and the System.Drawing
objects.
A faster method, although a more
complicated, Bitmap.SetPixel method is used.
IV. DETECTION/SEGMENTATION

Bitmap.SetPixel Method (cont.)


A method used to set the color of the
specified pixel in a bitmap object.
Syntax:
<bitmap>.SetPixel (<X-coordinate>,<Y-coordinate>)

The example on the next slide converts all


red pixels in the image to blue.
IV. DETECTION/SEGMENTATION

Bitmap.SetPixel Method
Example:
V. DETECTION/SEGMENTATION

Dilation and Erosion


Additional filtering maybe
applied to a binary image
thru mathematical pixel
operations such as dilation
and erosion.
Dilation expands objects into the background and is able
to eliminate salt noise and minimal cracks within an
object.
In contrast, erosion shrinks binary picture objects, and has
the effect of removing pepper noise and thin object
hairs.
V. DETECTION/SEGMENTATION

Advance Detection/Segmentation

Edge detection provides more rigorous means of segmentation


than thresholding by detecting color level discontinuities of an
object.
Two main methods of edge detection have been developed:
1. Template Matching (TM). Finding small parts of an image
which match a template image
2. Differential Gradient (DG). The intensity gradient
magnitude, if sufficiently large, is taken as a reliable
indicator of the edge of an object
IV. DETECTION/SEGMENTATION

Advance Detection/Segmentation (cont.)

Sample Edge detection


V. FEATURE EXTRACTION

Feature Extraction
Feature extraction is the
determination of geometric
features (such as area, border,
corners, centroid) and texture
of an object in a digital
image.
These information will then be
used for high-level processing
such further image
manipulation or AI application
for recognition and object
tracking.
V. FEATURE EXTRACTION

Feature Extraction (cont.)


The most basic analysis is area determination
of irregular objects thru pixel counting.
Below is an example of code for counting the
black pixels in a color array.
VI. HIGH-LEVEL PROCESSING AND DECISION MAKING

High-level Processing
High-level processing involves both extended
manipulation of a binary image to further
isolate the objects which will be analyzed
and application of artificial intelligence to
analyze the data from feature extraction.
Some high-level processing are as follows:
1. Resizing binary images thru size filtering
2. Object labeling and counting
3. Pattern Matching
4. Color Analysis
VI. HIGH-LEVEL PROCESSING AND DECISION MAKING

Decision Making
For recognition and prediction
applications, CV algorithms
may be extended thru the
creation of artificial
intelligence.
Artificial intelligence is the
capacity of a machine to
make pre-defined inferences
and decisions thru program
algorithm.
VII. COMPUTER VISION SOFTWARE PACKAGES

OpenCV
OpenCV (Open Source Computer
Vision) is a library of programming
functions mainly aimed at real-time
computer vision.
The libraries are added as
references or toolbox to
programming languages such as
C++, BASIC, and Matlab to provide
pre-programmed procedures for CV
applications.
OpenCV is released under a BSD
license and hence its free for both
academic and commercial use.
VII. COMPUTER VISION SOFTWARE PACKAGES

emgu CV
Emgu CV is a cross platform .Net
wrapper (adapter) to the
OpenCV image processing
library.
Allowing OpenCV functions to be
called from .NET compatible
languages such as C#, VB, VC++,
IronPython etc.
The wrapper can be compiled in
Mono and run on Windows, Linux,
Mac OS X, iPhone, iPad and
Android devices.
SUMMARY

Thru CV, machines gained the capacity to


see and perceive the physical reality.
However, computer vision requires
intermediate programming techniques.
Thru advance mathematical techniques,
objects can be isolated and analyzed for
features needed for decision making.
The availability of open-source libraries,
which can be referenced to common
programming languages, greatly simplified
the creation and use CV complex
algorithms
Thank you very much!
Next Chapter:
WORKING WITH SPREADSHEETS
Spreadsheet concepts
Spreadsheet programming
Developing macros in MS excel

Das könnte Ihnen auch gefallen