Image Processing: Robotics Club Summer Camp'12
Image Processing: Robotics Club Summer Camp'12
PROCESSING
ROBOTICS CLUB
SUMMER CAMP’12
WHAT IS IMAGE PROCESSING?
IMAGE
PROCESSING =
IMAGE
+
PROCESSING
WHAT IS IMAGE?
IMAGE = Made up of PIXELS
Each Pixels is like an array of Numbers.
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
0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0
GRAYSCALE
Each Pixel has a value from 0 to 255.
0 : black and 1 : White
Depth=8 (bits)
Number of Channels =1
GRAYSCALE IMAGE
RGB IMAGE
Depth=8 (bits)
Number of Channels = 3
RGB IMAGE
HSV IMAGE
Each pixel stores 3 values :-
H ( hue ) : 0 -180
S (saturation) : 0-255
V (value) : 0-255
Depth = 8 (bits)
Number of Channels = 3
#include "cv.h"
#include "highgui.h"
IMAGE POINTER
An image is stored as a structure IplImage with
following elements :-
int height Width
int width
int nChannels
int depth Height
char *imageData
int widthStep
….. So on
Initialising pointer to a image (structure) :-
IplImage* input
Depth
Number of Channels
output=cvCreateImage(cvGetSize(input),IPL_
DEPTH_8U,3)
CVWAITKEY( A NUMBER )
6 0 15 86 255 46 82
widthStep
Number of array elements in 1 row is stored in :-
input->widthStep
ACCESSING (I,J) PIXEL OF AN IMAGE
Grayscale
uchar *pinput = (uchar*)input-
>imageData;
int c = pinput[i*input->widthStep + j];
j
(0,0
i )
(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];
int r= pinput[i*input->widthStep + j*input-
>nChannels+2];
j
(0,0)
i