L.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
 2000 Prentice Hall, Inc. All rights reserved Fundamentals of Strings and Characters String declarations –Declare as a character array or a variable.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Characters and Strings.
Gavin S Page OpenCV Tutorial Part II Loading Images and Using Histograms 29 November 2005.
DIGITAL IMAGE PROCESSING CMSC 150: Lecture 14. Conventional Cameras  Entirely chemical and mechanical processes  Film: records a chemical record of.
By Rishabh Maheshwari. Objective of today’s lecture Play Angry Birds in 3D.
Bit Depth and Spatial Resolution SIMG-201 Survey of Imaging Science © 2002 CIS/RIT.
Gavin S Page OpenCV Tutorial Part IV A Brief Guide to Memory Management (and other Miscellaneous Functions) 02 December 2005.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
Image representation methods. Bitmap graphic method of a black-and-white image.
Graphics in the web Digital Media: Communication and Design
Week 7 – String. Outline Passing Array to Function Print the Array How Arrays are passed in a function call Introduction to Strings String Type Character.
Bitmapped Images 27 th November 2014 With Mrs
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Bitmapped Images. Bitmap Images Today’s Objectives Identify characteristics of bitmap images Resolution, bit depth, color mode, pixels Determine the most.
CSC – Java Programming II Lecture 9 January 30, 2002.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 3 Variables, Calculations, and Colors Starting Out with Games.
Filtering (I) Dr. Chang Shu COMP 4900C Winter 2008.
OpenCV Open source C omputer V ision library By: Bahare Torkaman Fall 2010.
Basics of a Computer Graphics System Introduction to Computer Graphics CSE 470/598 Arizona State University Dianne Hansford.
Detect Candle.  Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories  Choose "Show directories for: Include.
Images Data Representation. Objectives  Understand the terms bitmap & pixel  Understand how bitmap images are stored using binary in a computer system.
Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park.
C Tokens Identifiers Keywords Constants Operators Special symbols.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
© 1999 Rochester Institute of Technology Introduction to Digital Imaging.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
L. Akshay Masare Piyush Awasthi IMAGE PROCESSING AND OPENCV.
Introduction of OpenCV Alireza Shirani Researcher of Medical Image and Signal Processing M. S Electrical Engineering yahoo. com Spring.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Introduction to Image processing using processing.
W2D1. HSV colour model Source: Primary colours Red Green Blue Secondary Cyan Magenta.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
12/5/2015 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
` Tracking the Eyes using a Webcam Presented by: Kwesi Ackon Kwesi Ackon Supervisor: Mr. J. Connan.
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
COMPUTER GRAPHICS. Can refer to the number of pixels in a bitmapped image Can refer to the number of pixels in a bitmapped image The amount of space it.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
A brief introduction to doxygen. What does a compiler do?  A compiler ignores comments and processes the code.  What does doxygen do? –It ignores the.
1 ENGI 2420 Structured Programming (Lab Tutorial 8) Memorial University of Newfoundland.
June 14, ‘99 COLORS IN MATLAB.
Chapter 15 Strings as Character Arrays
Intelligent Robotics Today: Vision & Time & Space Complexity.
2/16/2016 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Characters and Strings
F28HS2 Hardware-Software Interface Lecture 6 - Programming in C 6.
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
Hank Childs, University of Oregon April “29 th”, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / /
Representation of image data
David Meredith Aalborg University
EEC-693/793 Applied Computer Vision with Depth Cameras
Processing the image with Python
Images In Matlab.
Color Tracking.
Reading Netpbm Images.
Computer Programming Methodology Files and Colors
Chapter 5 Working with Images
Representing Images 2.6 – Data Representation.
What do these words mean to you?
פרטים נוספים בסילבוס של הקורס
Nuts and Bolts of Digital Imaging
EEC-693/793 Applied Computer Vision with Depth Cameras
Hank Childs, University of Oregon
Basic Concepts of Digital Imaging
EEC-693/793 Applied Computer Vision with Depth Cameras
Non-numeric Data Representation
EEC-693/793 Applied Computer Vision with Depth Cameras
Presentation transcript:

l

Image processing and opencv Sakshi Sinha Harshad Sawhney

WHAT IS 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 ) widthStep Number of array elements in 1 row is stored in :- input->widthStep 6 15 86 255 46 82

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

Creates a window named ii 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.

Destroys window named ii cvReleaseImage( &input ) 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) Conv. type : CV_BGR2GRAY ,CV_BGR2HSV Saves input image in output pointer in other color space 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,iterations); Note:here NULL is a structural element Erodes an image for given number of iterations and saves it in output

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 (0,0) (i,j) i

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]; int r= pinput[i*input->widthStep + j*input->nChannels+2]; j i (0,0) B G 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