Hi, I'am currently trying to use cvInRangeS to check that the hue value of an HSV image is in some range. The problem is cvInRangeS allows the specification of only ONE continous range. In the following example is 20<=H<40 , 0<=S<255 , 0<=V<255 .
CvScalar lower = cvScalar (20, 0, 0);
CvScalar upper = cvScalar (40, 255,255);
cvInRangeS( hsv, lower, upper, output );
But i want to detect multiple ranges without having to call this function twice ( not very efficient). So I checked into the source code of cvInRangeS and tried to modify it in order that it allowed me to specify at least another set of ranges, but i'm not sure how to proceed. The source code of inRangeS is in cxcore/cxarithm.cpp. There there is some piece of code like this:
template<class Op> static void
inRangeS_( const Mat& srcmat1, const Scalar& _a, const Scalar& _b, Mat& dstmat )
{
....
for( int y = 0; y < size.height; y++, dst += dstep )
{
const typename Op::xtype* src1 = (const typename Op::xtype*)(srcmat1.data + srcmat1.step*y);
for( int x = 0; x < size.width; x++ )
dst[x] = op( src1[x], a, b ); // this line should be changed to sth like
//dst[x] = op( src1[x], a, b ) & op(src1[x],a1,b1);
}
}
the NEW function should receive at least two more parameters specifying a1 and b1 scalars.
I don't fully understand C++ template system so if someone could take a look into this file and give me some directions would be helpful. Thanks in advance!!