原图为:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <exception>
#include <stdio.h>
#include <vector>
#include <io.h>
#include <windows.h>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
using namespace cv;
using namespace std;
#define showSteps 1
int lowerH=0;
int lowerS=0;
int lowerV=0;
int upperH=180;
int upperS=256;
int upperV=256;
IplImage *frame = 0;
IplImage* imgThresh = 0;
//This function threshold the HSV image and create a binary image
IplImage* GetThresholdedImage(IplImage* imgHSV){
IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
cvInRangeS(imgHSV, cvScalar(lowerH,lowerS,lowerV), cvScalar(upperH,upperS,upperV), imgThresh);