IMAGE PROCESSING AND OPENCV. Sakshi Sinha Harshad Sawhney

Similar documents
OpenCV. Rishabh Maheshwari Electronics Club IIT Kanpur

Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV

ECE 661 HW6 Report. Lu Wang 10/28/2012

OpenCV. OpenCV Tutorials OpenCV User Guide OpenCV API Reference. docs.opencv.org. F. Xabier Albizuri

1. Introduction to the OpenCV library

ECE 661 HW 1. Chad Aeschliman

Introduction to OpenCV. Marvin Smith

OpenCV Introduction. CS 231a Spring April 15th, 2016

LAB SESSION 1 INTRODUCTION TO OPENCV

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut

Multimedia Retrieval Exercise Course 2 Basic Knowledge about Images in OpenCV

ECE 3331, Dr. Hebert, Summer-3, 2016 HW 11 Hardcopy HW due Tues 07/19 Program due Sunday 07/17. Problem 1. Section 10.6, Exercise 3.

ECE661 Computer Vision : HW2

ECE661 Computer Vision : HW1

ArduCAM USB Camera C/C++ SDK

Laboratory of Applied Robotics

Autonomous Golf Cart Vision Using HSV Image Processing and Commercial Webcam

Filtering (I) Agenda. Getting to know images. Image noise. Image filters. Dr. Chang Shu. COMP 4900C Winter 2008

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

Filtering (I) Dr. Chang Shu. COMP 4900C Winter 2008

Design Programming DECO2011

Real-Time Hand Gesture Detection and Recognition Using Simple Heuristic Rules

Representation of image data

CSIT 691 Independent Project. Video indexing

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

webcam Reference Manual

ArduCAM USB Camera SDK

Example 1: Color-to-Grayscale Image Processing

Problem 1. Multiple Choice (choose only one answer)

Lab 2. Hanz Cuevas Velásquez, Bob Fisher Advanced Vision School of Informatics, University of Edinburgh Week 3, 2018

Graphics Overview ECE2893. Lecture 19. ECE2893 Graphics Overview Spring / 15

Introduction to OpenCV

CS103L PA4. March 25, 2018

Physical Color. Color Theory - Center for Graphics and Geometric Computing, Technion 2

ECE264 Fall 2013 Exam 3, November 20, 2013

MCS 2514 Fall 2012 Programming Assignment 3 Image Processing Pointers, Class & Dynamic Data Due: Nov 25, 11:59 pm.

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Image Processing (1) Basic Concepts and Introduction of OpenCV

Binary representation and data

Visible Color. 700 (red) 580 (yellow) 520 (green)

CS 315 Data Structures Fall Figure 1

ECE 661 HW_4. Bharath Kumar Comandur J R 10/02/2012. In this exercise we develop a Harris Corner Detector to extract interest points (such as

Autonomous Rubik's Cube Solver Using Image Processing

CpSc 101, Fall 2015 Lab7: Image File Creation

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

OptimiData. JPEG2000 Software Development Kit for C/C++ Reference Manual. Version 1.6. from

Computer and Machine Vision

An Introduction to Video Compression in C/C++ Fore June

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Programming (1.0hour)

DECISION MAKING STATEMENTS

OpenCV Tutorial. Part II Loading Images and Using Histograms. 29 November Gavin S Page

Real-time image processing and object recognition for robotics applications. Adrian Stratulat

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

CSE/EE-576, Final Project

Color, Edge and Texture

COMS W4735: Visual Interfaces To Computers. Final Project (Finger Mouse) Submitted by: Tarandeep Singh Uni: ts2379

CHAPTER 4 SEMANTIC REGION-BASED IMAGE RETRIEVAL (SRBIR)

libtcod Documentation

An Implementation on Object Move Detection Using OpenCV

Augmented Feedback for Childhood Apraxia of Speech Design Specification Document

Optical Verification of Mouse Event Accuracy

C library = Header files + Reserved words + main method

4 4 4 RGB LED Cube kit Instruction Manual

Visual Computing in OpenCV Lecture 2: Dense Matrices

Decision Making and Loops

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

TEXT -> IMAGE ENCODING FLOWCHART (LSB METHOD) start. store color depth of screen. false. false initialize psuedo rand # generator.

Type Conversion. and. Statements

20 Dynamic allocation of memory: malloc and calloc

三維繪圖程式設計 3D Graphics Programming Design 第六章 Bitmap 影像及圖檔格式設定嘉大資工系盧天麒

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

CS 101 Media (Images, Video, etc) Lecture 20

Hue, Saturation & Intensity

Maximizing Face Detection Performance

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Object Move Controlling in Game Implementation Using OpenCV

CS4670 Final Report Hand Gesture Detection and Recognition for Human-Computer Interaction

UGviewer: a medical image viewer

ITP 140 Mobile App Technologies. Colors

void mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }

CSCI 512 / EENG 512 Computer Vision Spring Lab 6. February 17, 2016

Programming projects. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer

Authors: Terry Max Christy & Jeremy Borgman Advisors: Dr. Gary Dempsey & Nick Schmidt May 11, 2012

Goals of C "" The Goals of C (cont.) "" Goals of this Lecture"" The Design of C: A Rational Reconstruction"

Application Note ANGS [Issued date August 1, 2011]

COMP-202: Foundations of Programming. Lecture 26: Image Manipulation; Wrap-Up Jackie Cheung, Winter 2015

EE368 Project: Visual Code Marker Detection

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

CSC 1600 Memory Layout for Unix Processes"

Flying Start AS Computer Science. September 2015

Iteration in Programming

stanford hci group / cs377s Lecture 8: OpenCV Dan Maynes-Aminzade Designing Applications that See

Common File Formats. Need a standard to store images Raster data Photos Synthetic renderings. Vector Graphic Illustrations Fonts

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

This is not yellow. Image Files - Center for Graphics and Geometric Computing, Technion 2

Conditional Statement

Grayscale and Color Generation with SLA/MLA products

Kudan SLAM: User Manual. Generated by Doxygen

Transcription:

l

IMAGE PROCESSING AND OPENCV Sakshi Sinha Harshad Sawhney

WHAT IS IMAGE PROCESSING? IMAGE PROCESSING = IMAGE + PROCESSING

WHAT IS IMAGE? IMAGE = Made up of PIXELS. Each Pixels is like an array of Numbers. Numbers determine colour of Pixel. TYPES OF IMAGES : 1.BINARY IMAGE 2.GREYSCALE IMAGE 3.COLOURED IMAGE

BINARY IMAGE Each Pixel has either 1 (White) or 0 (Black) Depth =1 (bit) Number of Channels = 1

GRAYSCALE Each Pixel has a value from 0 to 255. 0 : black and 1 : White Between 0 and 255 are shades of b&w. Depth=8 (bits) Number of Channels =1

GRAYSCALE IMAGE

RGB IMAGE Each Pixel stores 3 values :R : 0-255 G: 0-255 B : 0-255 Depth=8 (bits) Number of Channels = 3

RGB IMAGE

HSV IMAGE Each pixel stores 3 values. In OpenCV H ( hue ) : 0-180 S (saturation) : 0-255 V (value) : 0-255 Depth = 8 (bits) Number of Channels = 3 Note : Hue in general is from 0-360, but as hue is 8 bits in OpenCV, it is shrinked to 180

STARTING WITH OPENCV OpenCV is a library for C language developed for Image Processing.

HEADER FILES FOR OPENCV After embedding opencv library in Dev C include following header files:- #include "cv.h" #include "highgui.h"

IMAGE POINTER An image is stored as a structure IplImage with following elements :int height int width int nchannels int depth char *imagedata int widthstep.. So on Width Height

imagedata An image s data is stored as a character array whose first element is pointed by :Input->imageData ( char pointer ) 6 0 15 86 255 46 82 widthstep Number of array elements in 1 row is stored in :input->widthstep

IMAGE POINTER Initialising pointer to a image (structure) :IplImage* input Load image to the pointer [0=gray;1=colored] input=cvloadimage("apple.jpg",1) Note :The image apple.jpg must be in same folder where you save your C program

cvnamedwindow("ii",1) Creates a window named ii 1 = Coloured 0 = Grayscale

Shows image pointed by input, in the window named ii

CREATE AN IMAGE To create an image you need to specify its : Size ( height and width) Depth Number of Channels output=cvcreateimage(cvgetsize(input),ipl_depth_8u, 3)

If 0 or negative number is given as input:waits indefinitely till key press and returns the ASCII value of the key pressed If positive number is given as input :Waits for corresponding milliseconds.

Command Function cvdestroywindow("ii") Destroys window named ii cvreleaseimage( &input ) Releases image pointer input from memory output=cvcloneimage(input) Copies image from input to output cvcvtcolor( input, output, conversion type) Saves input image in output pointer in other color space Conv. type : CV_BGR2GRAY,CV_BGR2HSV cvsaveimage("output.jpg",output) Saves image pointed by output naming it output cvdilate(input, output, NULL, iterations) Dilates an image for given number of iterations and saves it in output cverode(input,erode,null,iteration s); Erodes an image for given number of iterations and saves it in output Note:here NULL is a structural element

cvthreshold(input, output, threshold, maxvalue, thresholdtype) Threshhold types: CV_THRESH_BINARY max value if more than threshold, else 0 CV_THRESH_BINARY_INV 0 if more than threshold, else max value CV_THRESH_TRUNC threshold if more than threshold,else no change CV_THRESH_TOZERO no change if more than threshold else 0 CV_THRESH_TOZERO_INV 0 if more than threshold, else no change

SAMPLE CODE #include <cv.h> #define IMAGEWIDTH (640) #define IMAGEHEIGHT (480) int main(void) { IplImage *img; unsigned int x, y, channels, imgstep; unsigned char *imgdata; img=cvcreateimage(cvsize(imagewidth, IMAGEHEIGHT), IPL_DEPTH_8U, 3); channels = img->nchannels; imgstep = img->widthstep / sizeof (unsigned char); // Values per row imgdata = img->imagedata; for (y = 0; y < (img->height); y++) { for (x = 0; x < (img->width); x++) { imgdata[(y * imgstep) + (x * channels) + 0] = 255; // Blue imgdata[(y * imgstep) + (x * channels) + 1] = 128; // Green imgdata[(y * imgstep) + (x * channels) + 2] = 0; // Red } } return 0;

ACCESSING (I,J) PIXEL OF AN IMAGE Grayscale uchar *pinput = (uchar*)input->imagedata; int c = pinput[i*input->widthstep + j]; j i (0, 0) (i,j )

3 CHANNEL IMAGE (BGR):uchar *pinput = (uchar*)input->imagedata; int b= pinput[i*input->widthstep + j*input>nchannels+0]; int g= pinput[i*input->widthstep + j*input>nchannels+1]; j int r= ipinput[i*input->widthstep + j*input>nchannels+2]; (0,0) BGR BG R (i,j)

CHANNELS IplImage* blue=cvcreateimage( cvgetsize(frame), 8, 1 ); cvsetimagecoi( frame, 1 ); /*Here CvCopy sees the COI and ROI and then copies the channels to be copied. Here we set the first channel as the channel of interest*/ cvcopy( frame, blue, NULL ); /*Copy the first channel */

VIDEO POINTER CvCapture* capture - is a video pointer. To take video from camera :CvCapture *capture=cvcreatecameracapture(0); Note : Here 0 - Default & 1 - External To take video from a saved video file :CvCapture* capture=cvcreatefilecapture("trial.avi" );

TAKING IMAGE FROM CAMERA CvCapture *capture=cvcreatecameracapture(0); for(int i=0;i<100000000;i++); if(capture!=null) IplImage *frame=cvqueryframe(capture); Note : Here for loop is used to compensate time of initialization of camera in Windows

PLAYING VIDEO CvCapture *capture=cvcreatecameracapture(0); IplImage *frame; if(capture!=null){ frame=cvqueryframe(capture ); while(1){ cvshowimage( Video",frame); frame=cvqueryframe(capture); c=cvwaitkey(1);// frame rate if(c>0&&c<255) break; } }

MOUSE POINTER INFORMATION void my_mouse_callback(int event, int x, int y,int flags,void* param ){ uchar *pimage = (uchar*)image->imagedata; int r=pimage[y*image->widthstep + x*image->nchannels+2]; int g=pimage[y*image->widthstep+x*image->nchannels+1]; int b=pimage[y*image->widthstep x*image->nchannels+0]; printf( " x=%d y=%d r=%d g=%d b= %d\n",x,,y,,r,g,b); } main(){.. cvnamedwindow("image",1); cvsetmousecallback("image", my_mouse_callback, NULL); cvshowimage("image",image); } Note : cvsetmousecallback is set for a NamedWindow and not for an image.

IP PROBLEM STATEMENTS In general, all IP problem Statements have to discard one color and accept another in output image. Input Image Output Binary Image ` If( color pixel value > threshhold) output pixel=255; else output pixel =0; Note : In general, HSV format is highly useful to distinguish RGB colors ( Why? )

QUESTIONS

THANK YOU