24
BASICS

Image Processing Basics

Embed Size (px)

DESCRIPTION

Basics of IP by Robotix

Citation preview

Page 1: Image Processing Basics

BASICS

Page 2: Image Processing Basics

Q: WHAT IS IMAGE PROCESSING???

Accessing the data stored in an image and working with it is called Image Processing.

Page 3: Image Processing Basics

Q: WHAT IS AN IMAGE???

It’s a 2 dimensional array of pixels with each pixel having an unsigned value between 0 and 255.

Page 4: Image Processing Basics

SOME BASIC TERMINOLOGY USED IN Image Processing

Resolution: The resolution of an image defines how many pixels are there in the image, for example: if an image has the resolution of [ 800 X 600 ] it means that the image is a two dimensional array of size[800][600] that is 800 pixel in the horizontal direction for each of the 600 pixel in the vertical direction.

Page 5: Image Processing Basics

Pixel: Units which make up the image are called pixels. These contain some value depicting the shade of the particular cell.

Page 6: Image Processing Basics

Channel: It is the number of divisions in a particular pixel.

Eg: In a single channel image, the pixel has one value between 0 and 255. Eg: Grayscale

Image.

Page 7: Image Processing Basics

In a 3 channel image, each pixel will have 3 values between 0 and 255. The shade of that pixel will be the shade resulting from the combination of these 3 values. Eg: BGR image(Which is any coloured image we see) or and HSV Image.

Page 8: Image Processing Basics

Noise: Unwanted Part In an Image.

Binary Image: An Image which has only 2 shades (generally black and white).

Grayscale Image Binary Image

Page 9: Image Processing Basics

Threshold: Threshold in image processing is the value of a particular channel set by the programmer which is the border line between the wanted and the unwanted pixels. The image below shows an image thresholded into a binary image.

Page 10: Image Processing Basics

Histogram : A Graphical representation of the value of pixels versus the frequency of each pixel.

Page 11: Image Processing Basics

Q: HOW TO WORK WITH ALL THESE???

A Library called openCV contains Functions which helps us in accessing the image elements and working with them.

Page 12: Image Processing Basics

How to Start Working

Install Microsoft Visual Studio.

Install OpenCV .

Integrate OpenCV with Microsoft Visual Studio. (Procedure for linking given on our website : http://www.robotix.in/tutorials/ip ).

Page 13: Image Processing Basics

SAMPLE CODELOADING AN IMAGE STORED IN YOUR COMPUTER

#include "stdafx.h"#include <stdio.h>#include <cv.h>#include<iostream>#include"conio.h"#include <cxcore.h>#include <highgui.h>#include <stdlib.h>#include <windows.h>

int main( int argc, char **argv){cvNamedWindow("bgr image", CV_WINDOW_AUTOSIZE);//creating a window

for the image.cvMoveWindow("bgr image", 100, 100); //move it to 100, 100 position.

Page 14: Image Processing Basics

IplImage *frame=0;

frame = cvLoadImage("1.jpg");if( !frame ){printf("frame not captured properly");return 1;}

cvShowImage("bgr image", frame); // display the image

cvWaitKey(0);

cvReleaseImage(&frame);

return 0;}

Page 15: Image Processing Basics

LOADING AN IMAGE AND CONVERTING IT INTO A GRAYSCALE IMAGE.

int main( int argc, char **argv){cvNamedWindow("bgr image", CV_WINDOW_AUTOSIZE);//creating a window for the image.cvMoveWindow("bgr image", 100, 100); //move it to 100, 100 position.cvNamedWindow("grayscale img", CV_WINDOW_AUTOSIZE);//creating a window for the image.cvMoveWindow("grayscale img", 100, 100); //move it to 100, 100 position.

IplImage *frame=0;IplImage *grayscale=0;

frame = cvLoadImage("1.jpg");if( !frame ){printf("frame not captured properly");return 1;}

Page 16: Image Processing Basics

cvShowImage("bgr image", frame); // display the image

/* creating a single channel image of the same size as the original image*/grayscale = cvCreateImage( cvSize(frame->width, frame->height),

IPL_DEPTH_8U, 1 );

cvCvtColor(frame,grayscale,CV_RGB2GRAY);//for converting image into a grayscale image.

cvShowImage("grayscale img", grayscale); // display the imagecvWaitKey(0);cvReleaseImage(&frame);return 0;}

Page 17: Image Processing Basics

SOME USEFUL COMMANDSACCESSING THE VALUE OF PIXELS:

for(i=0;i<height;i++)//height is the image height{for(j=0;j<width;j++)//width is the image width{

k=image->imageData[i*height+j*nChannels]=0; printf(“The value of pixel [%d][%d] is %d”,I,j,k);}}The above commands prints the values of all the pixels in the

image oneby one

Page 18: Image Processing Basics

CLONING AN IMAGE

IplImage *img1=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1);

IplImage* img2;

img2=cvCloneImage(img1);// img2 is clone of img1

Page 19: Image Processing Basics

DO IT YOURSELF

Take a grayscale image and make its

histogram and display.

Page 20: Image Processing Basics

Sample Running Programs

• Histogram.

• Color Detection and Ball Following.

• Movement Detection.

Page 21: Image Processing Basics

ROBOTIX ’12 Image Processing EventNUKE-CLEAR

Problem Statement:

Build an autonomous image processing robot which can traverse around rooms, locate and disarm bombs.

Page 22: Image Processing Basics

HOW TO APPROACH THE PROBLEM STATEMENT?

Page 23: Image Processing Basics

ResourcesCodes can be found here.Image Processing Tutorial can be found hereNuke-Clear tutorial can be found here.

Page 24: Image Processing Basics

Hope You Enjoyed Learning Image Processing