Simple Image Processing and Object Detection using Matlab Akshar Prabhu Desai.

Slides:



Advertisements
Similar presentations
In InDesign, you can create a new file by pressing Command/Control-N.
Advertisements

1 ECE 495 – Integrated System Design I Introduction to Image Processing ECE 495, Spring 2013.
CS Spring 2009 CS 414 – Multimedia Systems Design Lecture 4 – Digital Image Representation Klara Nahrstedt Spring 2009.
ECE 472/572 - Digital Image Processing Lecture 10 - Color Image Processing 10/25/11.
Image Processing in Matlab An Introductory Approach by Sabih D. Khan
1 Video Processing Lecture on the image part (8+9) Automatic Perception Volker Krüger Aalborg Media Lab Aalborg University Copenhagen
CSSE463: Image Recognition Day 3 Announcements/reminders: Announcements/reminders: Lab 1 should have been turned in yesterday (due now if use a late day).
Computer Vision Lecture 3: Digital Images
Digital Images The digital representation of visual information.
Technology and digital images. Objectives Describe how the characteristics and behaviors of white light allow us to see colored objects. Describe the.
Simple Image Processing Speaker : Lin Hsiu-Ting Date : 2005 / 04 / 27.
6. COLOR IMAGE PROCESSING
Multimedia Data Introduction to Image Processing Dr Sandra I. Woolley Electronic, Electrical.
September 5, 2013Computer Vision Lecture 2: Digital Images 1 Computer Vision A simple two-stage model of computer vision: Image processing Scene analysis.
Image Representation. Digital Cameras Scanned Film & Photographs Digitized TV Signals Computer Graphics Radar & Sonar Medical Imaging Devices (X-Ray,
Presented By: ROLL No IMTIAZ HUSSAIN048 M.EHSAN ULLAH012 MUHAMMAD IDREES027 HAFIZ ABU BAKKAR096(06)
Introduction to Computer Graphics
Magic Camera Master’s Project Defense By Adam Meadows Project Committee: Dr. Eamonn Keogh Dr. Doug Tolbert.
CSSE463: Image Recognition Day 3 Announcements/reminders: Announcements/reminders: Lab 1 should have been turned in yesterday (due now if use a late day).
1 Mathematic Morphology used to extract image components that are useful in the representation and description of region shape, such as boundaries extraction.
Morphological Image Processing Robotics. 2/22/2016Introduction to Machine Vision Remember from Lecture 12: GRAY LEVEL THRESHOLDING Objects Set threshold.
Machine Vision. Image Acquisition > Resolution Ability of a scanning system to distinguish between 2 closely separated points. > Contrast Ability to detect.
CSSE463: Image Recognition Day 3 Announcements/reminders: Announcements/reminders: Lab 1 should have been turned in yesterday (due now if use a late day).
An Introduction to Digital Image Processing Dr.Amnach Khawne Department of Computer Engineering, KMITL.
Image Processing Intro2CS – week 6 1. Image Processing Many devices now have cameras on them Lots of image data recorded for computers to process. But.
Leaves Recognition By Zakir Mohammed Indiana State University Computer Science.
Image Enhancement in the Spatial Domain.
Color Models Light property Color models.
BITMAPPED IMAGES & VECTOR DRAWN GRAPHICS
DIGITAL MEDIA FOUNDATIONS
(Project) by:- ROHAN HIMANSHU ANUP 70282
ITEC2110, Digital Media Chapter 2 Fundamentals of Digital Imaging
John Federici NJIT Physics Department
Hand Gestures Based Applications
Images Data Representation.
Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny
Sampling, Quantization, Color Models & Indexed Color
Color Image Processing
Color Image Processing
Color Image Processing
Processing the image with Python
Introduction to Electromagnetic waves, Light, and color
Compression (of this 8-bit 397,000 pixel image):
Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny
Chapter 6: Color Image Processing
Color Image Processing
Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny
Color Image Representation
COMS 161 Introduction to Computing
Chapter 12 COLOR THEORY.
Other Algorithms Follow Up
Computer Vision Lecture 3: Digital Images
CSSE463: Image Recognition Day 3
Color Image Processing
CSC 381/481 Quarter: Fall 03/04 Daniela Stan Raicu
Spatial operations and transformations
Color Image Processing
Department of Computer Engineering
Digital Image Processing
Magnetic Resonance Imaging
Midterm Exam Closed book, notes, computer Similar to test 1 in format:
Basic Concepts of Digital Imaging
CSSE463: Image Recognition Day 3
© 2010 Cengage Learning Engineering. All Rights Reserved.
Midterm Exam Closed book, notes, computer Similar to test 1 in format:
Non-numeric Data Representation
Computer and Robot Vision I
Computer and Robot Vision I
Introduction to Artificial Intelligence Lecture 22: Computer Vision II
Spatial operations and transformations
Presentation transcript:

Simple Image Processing and Object Detection using Matlab Akshar Prabhu Desai

Objectives A quick introduction to matlab Color models and their representation in matlab Generating and analyzing histograms Noise reduction Detecting objects of interest in image A graded lab assignment at the end Download links given at the end

The Setup A webcam connected to your Windows machine Matlab R2009a A table tennis ball Chart paper of different colors

Matlab Introduction MATrix LABolatory The basic data type is a matrix Basic features – Arithmetic and logical operations – Plotting – Signal Processing

Getting Started Create a File with name First.m Open Matlab and Select File > open and select this file To run a file click on the run icon

Defining matrix >> d=[ ; ; ] This is a 2D matrix Functions can be applied to the matrix – >> determin= det(b) ; %determinant – >> I = inv(b); %inverse % can be used to write comments

The image This is the image we have captured using our setup. We have deliberately kept some ambience in the left hand side compared to the ideal right hand side image.

Capturing Images using Matlab imaqreset %reset clear all vidobj = videoinput('winvideo',1); %capture the device handle set(vidobj, 'FramesPerTrigger',1); % each time we call trigger one frame gets captured set(vidobj, 'TriggerRepeat',inf); % we can have infinite triggers triggerconfig(vidobj, 'manual'); % the trigger will be called manually. We can also set times for the same start(vidobj); % start the device capture i=1; n=1; % get while 1, – trigger(vidobj); % capture one frame frame=getdata(vidobj); % frame is a matrix that stores the frame imshow(frame); n = n + 1; – if(n>300),% we are capturing total of 300 frames – stop(vidobj); % never forget to close the device handle – break; – end end i=i+1; Only the red code changes as we move on rest of the code remains same.

Color Models RGB CMY and CMYK HSI And there are more

RGB model Three primary spectral components More suitable for Monitors The diagonal passing through origin is the gray scale model.

CMY Cyan, Magenta and Yellow 1- cyan = red (it means a cyan surface does not reflect red at all) More suitable for printing Guess why do we need CMYK model ? (K- is black) CMY model is more suitable for image processing

Understanding the Image Matrix The “frame” is a 3D matrix. There are 3x2D matrixes each composed of R,G and B components. Here are the R G B components separated and displayed R GB

The code to display R component while 1, trigger(vidobj); % capture one frame frame=getdata(vidobj); % frame is a matrix that stores the frame imshow(frame(:,:,1)); % displaying R component, to display G and B change 1 to 2 and 3 respectively n = n + 1; if(n>300),% we are cpatuing total of 300 frames stop(vidobj); % never forget to close the device handle break; end

Converting to Grayscale RGB image is a 3D array we can convert it to Grayscale using the function rgb2gray. We can build full color images from gray scale components as well. We get a 2D array to process.

The histogram Histogram is a plot of color and the statistical frequency of that color in the image. imhist(im); is the command to get an histogram.

Why histograms matter The object we need to detect will have a certain color. We can detect the object by simply setting all the pixels that fall in that color’s frequency range to 1 and rest to zero. For Example:

For our image Making all pixels above 150 to white rest all black. Making all pixels above 200 to white rest all black. Code on next slide

The code while 1, trigger(vidobj); % capture one frame frame=getdata(vidobj); % frame is a matrix that stores the frame bw = rgb2gray(frame); bw = im2bw(frame,0.78); % 0.78 = 200/255 imshow(bw); n = n + 1; if(n>300),% we are cpatuing total of 300 frames stop(vidobj); % never forget to close the device handle break; end

Image Detection Images can be detected based on only color, only shape or combination of both. Thresh-holding can be used easily where we have the freedom to chose the environment colors. For example

Histogram & thresh-holding Code for these three is on next slide Our ball color is here imshow(im2bw(bw,0.28));

The code while 1, trigger(vidobj); % capture one frame frame= getdata(vidobj); % frame is a matrix that stores the frame, getdata is a inbuilt function that retrieves image from the camera handle bw = rgb2gray(frame); imshow(im2bw(bw,0.28)); % 0.28 = x/255 n = n + 1; if(n>10),% we are capturing total of 10 frames stop(vidobj); % never forget to close the device handle break; end

The function reference ages/ref/im2bw.html ages/ref/im2bw.html Above URL provides detailed list of inbuilt function related to image processing

Limitations Note that this works because the environment colors are decided by us. In real world this kind of thing will not work. This tutorial is limited to this approach only

Location of the object in image Please read up what is filters and convolution. We use wiener filter to remove the noise from the filtered image. Code: bw = rgb2gray(frame); bw = im2bw(bw,0.28); bw = wiener2(bw,[12 12]); imshow(bw);

The concept of noise Consider the image Noise Object

Noise Detection How do we convert into human perception of noise into something that can be detected mathematically ? One solution: Any pixel which is not similar to it’s neighborhood pixels can be due to noise. By looking at the neighborhood of the pixel we can make some assumption about a pixel. Notion of filtering uses this as basis.

Wiener Filter It’s a noise reduction filter It’s description is beyond the scope of discussion but you should read up more about – Convolution (signal processing)

Object Detection and labeling Here we use an inbuilt function to do thresholding and boundary detection and then annotate the detected objects. The histogram and thresholding techniques can be used by you to tune your environment colors.

Object Detection and Labelling Matlab provides a function ‘bwboundaries’ which can be used for detecting boundaries of a binary image. We provide our filtered noiseless image to this function and it detects the boundaries for us: Original Image Detecting the boundaries and co- ordinates

Here is the result of final program

The complete program The complete program can be downloaded from

More on matlab Matlab provides a large number of inbuilt filters (refer to the function manual) We can also define our own image filters We can convert images from one Color model to other. CMY model is usually very good for color based detection

Two kinds of Object Detection Color based Shape based We have explained only color based detection here. Shape based detection is more complex.

Controlling Robot Matlab can issue commands to communicate with the robot using serial communication Most of us would want the robot to go near the detected object.

Algorithm Detect the Object in the image Find the center of the detected object Try to move the robot such that the center of the object is same as the center of the image

Example Code if row < 220 'go ahead' elseif row > 260 'go back' elseif col>380 'go right' elseif col<320 'go left' else 'stop' end break; Row, column is the co-ordinates of the center of the image.

Thank You