Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV

Similar documents
Multimedia Retrieval Exercise Course 2 Basic Knowledge about Images in OpenCV

IMAGE PROCESSING AND OPENCV. Sakshi Sinha Harshad Sawhney

OpenCV. Rishabh Maheshwari Electronics Club IIT Kanpur

Intro to Multimedia Retrieval Exercise Course 3 Query by Example: Color Histogram Extraction

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

1. Introduction to the OpenCV library

Chapter 6. Introduction to OpenCV

Intro to Multimedia Retrieval Exercise Course 4 Query by Example: Similarity Computation

ECE 661 HW 1. Chad Aeschliman

CS103L PA4. March 25, 2018

IMPLEMENTATION OF COMPUTER VISION TECHNIQUES USING OPENCV

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

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

LAB SESSION 1 INTRODUCTION TO OPENCV

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

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

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

OpenCV. Basics. Department of Electrical Engineering and Computer Science

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

CSIT 691 Independent Project. Video indexing

Computer and Machine Vision

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

Problem Solving: Storyboards for User Interaction

Multimedia Retrieval Exercise Course 10 Bag of Visual Words and Support Vector Machine

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

ECE661 Computer Vision : HW2

Representation of image data

B.E.I.T. ( ) 3D

Transportation Informatics Group, ALPEN-ADRIA University of Klagenfurt. Transportation Informatics Group University of Klagenfurt 12/24/2009 1

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

Introduction to OpenCV

Linked List using a Sentinel

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

C++ Structures Programming Workshop 2 (CSCI 1061U)

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

typedef Labeling<unsigned char,short> LabelingBS; typedef Labeling<unsigned char,short>::regioninfo RegionInfoBS;

COMP322 - Introduction to C++

CS 315 Data Structures Fall Figure 1

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

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

Programming. C++ Basics

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

Assignment 1 - Use OpenCV for camera calibration

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

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

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.

Introduction to OpenCV. Marvin Smith

webcam Reference Manual

C++ For Science and Engineering Lecture 12

Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

An Implementation on Object Move Detection Using OpenCV

WARM UP LESSONS BARE BASICS

CSE 333. Lecture 10 - references, const, classes. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington

Introduction to C++ Systems Programming

UEE1302(1066) F12: Introduction to Computers and Programming. Lab 12: Pointer & Dynamic Array (II)

ECE661 Computer Vision : HW1

Exercise 1.1 Hello world

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements:

How to Accelerate OpenCV Applications with the Zynq-7000 All Programmable SoC using Vivado HLS Video Libraries August 28, 2013

C++ For Science and Engineering Lecture 15

CS24 Week 3 Lecture 1

version July 2003

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Intermediate Programming, Spring 2017*

Data Structures Unit 02

6.096 Introduction to C++ January (IAP) 2009

Parallel Image Processing

BEng (Hons) Electronic Engineering. Resit Examinations for / Semester 1

Application Note ANGS [Issued date August 1, 2011]

Programming in C/C Lecture 2

Interaction Technology

CS 376b Computer Vision

PROGRAMMING IN C++ KAUSIK DATTA 18-Oct-2017

Image Processing (1) Basic Concepts and Introduction of OpenCV

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

struct Buffer { Buffer(int s) { buf = new char[s]; } ~Buffer() { delete [] buf; } char *buf; };

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0

Arrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff

Autonomous Golf Cart Vision Using HSV Image Processing and Commercial Webcam

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

CMPS 221 Sample Final

Homework Assignment #2 (revised)

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

Tokens, Expressions and Control Structures

Topics. bool and string types input/output library functions comments memory allocation templates classes

Programming Fundamentals. With C++ Variable Declaration, Evaluation and Assignment 1

Computational Physics

CSE 303, Spring 2006, Final Examination 6 June Please do not turn the page until everyone is ready.

heman Documentation Release r1 Philip Rideout

Computer Programming : C++

Week 5: Files and Streams

Example 1: Color-to-Grayscale Image Processing

Bruce Merry. IOI Training Dec 2013

Introduction to OpenCV

Chapter 15 - C++ As A "Better C"

Project Implementation

Recognition in Video (Tutorial at CCECE 06, Ottawa, 7 May 2006)

Transcription:

Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV Kimiaki Shirahama, D.E. Research Group for Pattern Recognition Institute for Vision and Graphics University of Siegen, Germany

Last lesson s Program Read an image and show it in a dialog int main(){ IplImage* img = cvloadimage("c:\\opencv\\samples\\c\\cat.jpg", CV_LOAD_IMAGE_COLOR); cvnamedwindow("test", CV_WINDOW_AUTOSIZE); cvshowimage("test", img ); cvwaitkey(0); cvreleaseimage(&img); } The image filename assumes Windows. Please change it depending on your PC s OS.

Overview of Today s Lesson 1. IplImage - Structure of IplImage - cvloadimage - cvcreateimage - cvreleaseimage - Access to image pixels 2. Useful functions in HighGUI - cvnamedwindow - cvshowimage - cvwaitkey 3. Examples of simple image processing - Image resize - Color space conversion - Edge detection

OpenCV Information Useful web page: http://opencv.jp/opencv-1.1.0_org/docs/index.htm CXCORE: Functions for basic data structures in OpenCV CV: Functions for image processing and analysis ML (Machine Learning): Functions for statistical classification, regression and clustering HighGUI: High-level GUI and Media I/O

IplImage Structure of the header for representing an image on the memory typedef struct _IplImage { // Variables regarding properties of an image int width; int height; int imagesize; int nchannels; // Variables regarding how an image is stored char *imagedata; int origin; int depth; int widthstep; // Variable regarding a specified region in an image struct _IplROI *roi (many other variables) } IplImage; IplImage* img (imagedata) (IplImage) Memory char *imagedata

IplImage->imageData typedef struct _IplImage { // Variables regarding how an image is stored char *imagedata; // ONE-dimensional array for storing pixel values int origin; // Which pixel is represented by the first element in imagedata int depth; // How many bits are used to represent the value of one channel in each pixel int widthstep; // How many bits are used to represent pixels in one row } IplImage; By default, origin = 0 (top-left origin) The size of each element ( B G R ) is specified by depth (IPL_DEPTH_8U (default): Each element is 8bit unsigned char) B G R B G R B G R B G R B G R B G R Values of pixels in the 0-th row (widthstep bytes) Values of pixels in the 1-th row (widthstep bytes)

Useful and Necessary Functions for IplImage 1. IplImage* cvloadimage( const char* filename, int flags=cv_load_image_color ) CV_LOAD_IMAGE_COLOR is usually OK. If you want to load an image in the grayscale mode, use CV_LOAD_IMAGE_GRAYSCALE. 2. IplImage* cvcreateimage( CvSize size, int depth, int channels ) This function is often used to allocate an IplImage region, to which the already loaded image (pointed by IplImage*) is copied or converted. Thus, by imaging the copied or converted region, input variables should be appropriately set. -> This function will be used later. 3. void cvreleaseimage( IplImage** image ) This function is very important for avoiding out-of-memory. Allocated IplImage regions should be appropriately released by yourself. It should be noted that the input variable is the pointer of the pointer of IplImage!

Checking variables in IplImage Please try to add some sentences to the last lesson s code, in order to check the width, height, and nchannels of IplImage. The code will come after the lesson Some tips 1. While the most basic function for outputing texts to a terminal is printf of C, cout of C++ is a more convenient because it can automatically recognise the variable types. The summary of using cout is as follows: #include <iostream> using namespace std; // If this is missing, cout has to be written as std::cout NOTE: Variable type recognition does not work for unsigned char! 2. For windows users, due to the specification of Visual C++, a terminal will quickly disappear after reaching the end of a program. To keep the terminal appearing, one of the simplest approach is as follows: int a = 0; cin >> a; // Wait until some value is input into a

Accessing Pixels in Images though IplImage Please try to print the value of each pixel, using for loop based on the structure of IplImage->imageData The code will come after the lesson Some tips 1. Use printf ( cout does not work) 2. Store pixel values into an array of unsigned char

Useful Functions in HighGUI 1. int cvnamedwindow( const char* name, int flags=cv_window_autosize ) The first variable specifies the name of the window where an image is shown. 2. void cvshowimage( const char* name, const CvArr* image ) Using the first variable, you can specify which window is used to show an image 3. void cvdestroywindow( const char* name ) Release the memory used for the window 4. int cvwaitkey( int delay=0 ) The function is used to wait for some key input or delay milliseconds. The return value represent which key is pressed. Returns the code of the pressed key

Simple Image Processing (1) - Image Resize - void cvresize( const CvArr* src, CvArr* dst, int interpolation=cv_inter_linear ) The first and second variables represent the source and resized image (which can be Specified by IplImage*). The last variable indicates what kind of approximation is conducted to create the resized image. The code will come after the lesson

Simple Image Processing (2) - Color Space Conversion - RGB color space - Red - Green - Blue Not intuitive for humans HSV color space - Hue: Primary color - Saturation: Effect of white - Value: Darkness (effect of black) More intuitive for humans G S B H V R void cvcvtcolor( const CvArr* src, CvArr* dst, int code ) The first and second variables represent the source and result image (which can be specified by IplImage*). The last variable indicates what kind of color conversion is conducted. The code will come after the lesson

Simple Image Processing (3) - Edge Detection - void cvcanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 ) The first and second variables represent the source and result image (which can be specified by IplImage*). The third variable is used to examine the connection of edges. The forth variable is used to detect strong edges in the initial process. The last variable specifies the size of Sobel filter. Please test various values. The code will come after the lesson threshold1=50, threshold2=200, aperture_size=3 (do not need to specify)