Friday, 8 February 2013

Colour: Detecting an object of a particular colour

In OpenCV, images are captured in BGR format. For this project, we convert the format from BGR to HSV as it is most suitable colour space for colour based image segmentation. Each pixel in HSV image is represented by 3 matrices; Hue-represent the color, Saturation-mixture with black, Value-mixture with black. The following functions are used in the code;
-cvCvtcolour(*source, *dest, * code of color conversion )

Next, we threshold the image. This would create a binary image, where the selected colour will turn to white, while other part of the image turns black. The following function is used;
-cvInRangeS(const CvArr* src, CvScalar lower, CvScalar upper, CvArr* dst)



Picture above shows the threshold of the image, in which green colour was selected.

No comments:

Post a Comment