Matlab Computer Vision PDF
Matlab Computer Vision PDF
MATLAB
4
Key Industries
5
Image and Video Processing with MATLAB
Key Take Aways
High-level language
Development environment
6
Agenda
Welcome and Introductions
Image Processing with MATLAB
Computer Vision with MATLAB
Break
Programming Techniques
Speeding-up your Applications
Break
Deploy your Applications
Target External Devices
Summary
7
Applications: Image and Video Processing
Medical imaging
Surveillance
Robotics
Automotive safety
Consumer electronics
Geospatial computing
Machine vision
and more
8
Technical Computing Tasks
Algorithm
Software Outputs for Design
Development
Automate
10
Lets perform some image processing?
11
Demo: Candy Counter
12
Algorithm Summary
Image Enhancement
Morphological Operators
Image Segmentation
Thresholding
Color Segmentation
Image Analysis
Object properties and statistics
13
Image Segmentation Other Methods
Active Contours and Watershed
14
Image Enhancement
Deblurring and Noise Removal
15
Image Registration
2-D & 3-D Image Alignment
Align multimodal images
16
Image Processing with Live Video
17
Image Processing Apps:
Segment Tool, MorphTool, Image Registration App
21
Typical Parts of a Computer Vision Algorithm
22
Face Detection, People Detection, and
Background Subtraction
23
Demo: Face tracking with a webcam
+ =
24
Stereo Vision (14a)
Stereo calibration
Semi-global disparity matching
Better results than block matching
3D scene reconstruction from
disparity
New demos available
Estimate real distance to objects in
video
3D scene reconstruction
Pedestrian detection (14b)
29
OCR Optical Character Recognition (14a)
32
Camera Calibration App: Demo
Automatically detects
checkerboard patterns
35
Computer Vision Apps on File Exchange
CascadeTrainGUI App, CV ImageRegistration App
value
variable
structure
Data
(properties)
41
How are System objects different from
MATLAB functions?
Batch
Source Video
Algorithm
Stream Stream
Source Processing
44
Video Processing in MATLAB Before
Video processing is difficult in MATLAB
myVid = mmreader(myvideofile.avi);
numFrames = myVid.NumberOfFrames;
numIter = 10;
opticalFlowIn = zeros([size(currentFrame) 5]);
opticalFlowOutput = zeros([size(currentFrame) numFrames]);
flow = opticalFlow(opticalFlowIn(:,:,1),opticalFlowIn(:,:,5),
horn-schunck,numIter,magitude-squared);
opticalFlowOutput(:,:,i) = flow;
Explicit indexing
i = i+1;
end
Needs a buffer
implay(opticalFlowOutput,30)
45
Video Processing in MATLAB After
Video processing is difficult in MATLAB
reader = video.MultimediaFileReader
reader.Filename = myvideofile.avi; Object
viewer = video.DeployableVideoPlayer initialization
optical = video.OpticalFlow
optical.Method = horn-schunck;
optical.OutputValue = Magitude-squared;
optical.ReferenceFrameDelay = 3;
optical.MaximumIterationCount = 10;
46
Summary System Objects
48
Agenda
Welcome and Introductions
Image Processing with MATLAB
Computer Vision with MATLAB
Break
Programming Techniques
Speeding-up your Applications
Break
Deploy your Applications
Target External Devices
Summary
49
Images & Processing Demands on the Rise
50
Solving Larger Problems
51
Using More Hardware
Built-in multithreading
Automatically enabled in MATLAB since R2008a
Multiple threads in a single MATLAB computation engine
www.mathworks.com/discovery/multicore-matlab.html
52
GPU vs. CPU Comparison
Features CPU GPU
# of Threads 10s 100s 100s 1000s
vs.
54
GPU Acceleration for 43 functions
bwmorph imhist
bwlookup imnoise
corr2 imopen
edge imresize
histeq imrotate
imadjust imshow
imbothat imtophat
imclose imwarp
imdilate mean2
imerode medfilt2
imfilter padarray
imgradient rgb2gray
55
Criteria for Good Problems to Run on a GPU
Massively parallel:
Calculations can be broken into hundreds
or thousands of independent units of work
Problem size takes advantage of many GPU cores
Computationally intensive:
Computation time significantly exceeds CPU/GPU data transfer time
56
Example: Solving 2D Wave Equation
GPU Computing
58
Benchmark: Solving 2D Wave Equation
GPU Computing
CPU GPU
Grid Size Speedup
(s) (s)
60
Demo: filtering a large Image
Using blockproc and Built-in Parallel Support
61
Independent Tasks or Iterations
Parallel for-loops
Tim Tim
e e
blogs.mathworks.com/loren/2009/10/02/using-parfor-loops-getting-up-and-
running/
62
Demos: GPU Computing, Blockproc, Parallel
64
Demo: Brain Scan and GPU Computing
Summary
gpuBenchmark
65
Noisy Image
Demo: Filtering a large Image
Summary
http://hirise.lpl.arizona.edu/
From - NASA/JPL/University of Arizona
67
Demo: Candy Counter parallel for loop and batch
Summary
Converted for-loop
into parfor-loop
68
Take Advantage of Cluster Hardware
Offload computation:
Computer Cluster
Free up desktop
Access better computers Cluster
Scale speed-up:
Use more cores
Go from hours to minutes
MATLAB Scheduler
Desktop (Client)
Scale memory:
Utilize distributed arrays
Solve larger problems without re-coding algorithms
69
Heart Transplant Studies
3-4 weeks reduced to 5 days
70
Offload Computations with batch
Work Worker
MATLAB
Desktop (Client) Worker
Worker
Result
Worker
batch()
71
Offload and Scale Computations with batch
Work Worker
MATLAB
Desktop (Client) Worker
Worker
Result
Worker
batch(,'Pool',)
72
Distributing Large Data
11 26 41
12 27 42
13 28 43
14 29 44
Worker 15 30 45
MATLAB 16 31 46
Desktop (Client) 17 32 47
Worker
Worker 17 33 48
19 34 49
20 35 50
Worker
21 36 51
22 37 52
Algorithm
Software Outputs for Design
Development
Automate
77
Next Steps - Sharing Results from MATLAB
Publish reports
Package as an App
Deploy applications
Deploying C Code
78
Publish Reports
79
Packaging and Sharing MATLAB Apps
MATLAB apps
Interactive applications to perform
technical computing tasks
Displayed in apps gallery
80
Deploying Applications - MATLAB Compiler
Share applications
toolboxes
Requires MATLAB
Compiler Runtime
Free run-time library .exe .dll Excel Java Web COM .NET
Royalty-free deployment
81
Deploying C Code - MATLAB Coder
Generate C code
Royalty-free deployment
.c .lib
82
MATLAB Compiler and MATLAB Coder
.exe .dll .c
83
MATLAB Compiler or MATLAB Coder?
MATLAB Coder
MATLAB Compiler
Readable
Builders, MPS Desktop
Portable
.dll .c
.cpp
Web .exe
Excel
.NET
Java
.exe
84
Code Generation for 41 IPT Functions
padarray imhmax
bwmorph imhmin
bwlookup imreconstruct
conndef imregionalmax
fspecial iptcheckconn
imcomplement label2rgb
imfill
85
Code Generation for ALL 86 CVST Functions
86
Why Engineers Translate MATLAB to C Today
.c
87
Automatic Translation of MATLAB to C
.c
e
rat
i te
.exe
.lib
Algorithm Design and .dll
Code Generation in
verify
MATLAB a cce /
lerate
MEX
88
Choosing the Right Deployment Solution
MATLAB Coder and MATLAB Compiler
.c
Full language
Subset of language
MATLAB support Most toolboxes
Some toolboxes
Graphics
MATLAB Compiler
Runtime requirement Runtime
None
90
Deployment: Demos
MATLAB Compiler, MATLAB Coder, and Apps
91
Agenda
Welcome and Introductions
Image Processing with MATLAB
Computer Vision with MATLAB
Break
Programming Techniques
Speeding-up your Applications
Break
Deploy your Applications
Target External Devices
Summary
92
Target External Hardware
Code Generation Technologies
Embedded Coder
Automatically generate C and C++
Embedded optimized for embedded systems
Coder comparable to the efficiency of
handwritten code
Simulink Coder
Automatically generate C and C++ from
Simulink
Coder Simulink models and Stateflow charts
for Rapid Prototyping and Hardware-in-
the-Loop
93
Target External Hardware
Simulink Hardware Support
94
Target External Hardware
Example Raspberry Pi
Raspberry Pi hardware
support package
Capturing live data from
sensors and imaging devices
(camera board)
Connects to MATLAB over
Ethernet (wired or wireless)
95
Raspberry Pi Hardware Setup
Connect Raspberry Pi
Plug in USB Ethernet Adapter to PC,
and Ethernet cable into adapter and
Raspberry Pi
Plug USB webcam into Raspberry Pi
Insert SD card (which may be a carrier
for SD micro) into Raspberry Pi
Attach USB power cable USB A to
PC, and USB micro B to power port on
Raspberry Pi
Wait a minute for Raspberry Pi to boot
Object Detection
Locate and mark the center of green object
Barcode scanner
Scan barcode and output numerical digits
97
Agenda
Welcome and Introductions
Image Processing with MATLAB
Computer Vision with MATLAB
Break
Programming Techniques
Speeding-up your Applications
Break
Deploy your Applications
Target External Devices
Summary
98
Image and Video Processing with MATLAB
Key Take Aways
High-level language
Native support for vector and matrix operations
Built-in math and visualization functions
Development environment
Interactive and easy to get started
Ideal for iterative exploration and design
99
Why use MATLAB for Image Processing?
100
Image Processing Toolbox
Image analysis
Image enhancement
Geometric transformation
Image registration
Morphological operations
ROI-based processing
Image display and exploration
101
Why Use MATLAB for Computer Vision?
103
Image Acquisition Toolbox
Manufacturers include:
Allied Vision Technologies
Basler
Baumer
FLIR
Hamamatsu
Point Grey
Teledyne DALSA
See Hardware Catalog for more details: www.mathworks.com/hardware
104
Support and Community
105
Consulting Services
Accelerating return on investment
A global team of experts supporting every stage of tool and process integration
Continuous Improvement
Automation
Process and Technology
Standardization
Full Application
Deployment
Process Assessment
Component
Deployment
Advisory Services
Jumpstart
Migration Planning
106
Training Services
Exploit the full potential of MathWorks products
107
MATLAB Central
File Exchange
Access more than 10k free files
including functions, apps, examples,
and models
MATLAB Answers
Ask programming questions or search
18k+ community-answered Questions
Newsgroup
Participate in technical discussions
1,400 posts per day
Blogs
Read commentary from engineers who
design, build, and support MathWorks products
MATLAB and
Simulink interfaces, Embedded processors, real-
toolboxes and libraries time systems and
instrumentation
109
Book Program
110
From a Leading Textbook Author ...
Rafael C. Gonzalez
Professor Emeritus
University of Tennessee
111
Technical Support
Resources High customer satisfaction
Over 100 support engineers 95% of calls answered
All with MS degrees (EE, ME, CS) within three minutes
Local support in North America, 70% of issues resolved
Europe, and Asia within 24 hours
Comprehensive, product-specific Web 80% of customers surveyed
support resources rate satisfaction at 80100%
112
For More Information
113
Thank You for Attending Todays Seminar
115
Dr. Roland Michaely
Application Engineer