That means that each elemnt of the destination array is created by subtracting the scalar from the corresponding element (cotrresponding by index) in the source array. The same applies to the other function usind addition instead and a mask value.

Solved

Posted on 2007-07-30

If anyone can help me understand what this function does, I would appreciate it:

cvAbsDiffS(Image1, Image2, s);

What is the functions doing to the array? How does it use "s" scalar value to do that? Finally, this function and cvSubS have been suggested to select out pixel hue ranges to isolate color in HSV space. I understand HSV space, just not what these functions are doing to the arrays passed through them.

AbsDiffS

Calculates absolute difference between array and scalar

void cvAbsDiffS( const CvArr* A, CvArr* C, CvScalar S );

#define cvAbs(A, C) cvAbsDiffS(A, C, cvScalarAll(0))

A

The source array.

C

The destination array.

S

The scalar.

The function cvAbsDiffS calculates absolute difference between array and scalar.

C(I)c = abs(A(I)c - Sc).

All the arrays must have the same data type and the same size (or ROI size).

------------------

SubS

Computes difference of array and scalar

void cvSubS( const CvArr* A, CvScalar S, CvArr* C, const CvArr* mask=0 );

A

The source array.

S

Subed scalar.

C

The destination array.

mask

Operation mask, 8-bit single channel array; specifies elements of destination array to be changed.

The function cvSubS subtracts a scalar from every element of the source array:

C(I)=A(I)+S if mask(I)!=0

All the arrays must have the same type, except the mask, and the same size (or ROI size)

----------------------------------------

If I understood what calculations were being employed, I could pick the correct S scalar value to choose a hue range.

Help...

WLE

cvAbsDiffS(Image1, Image2, s);

What is the functions doing to the array? How does it use "s" scalar value to do that? Finally, this function and cvSubS have been suggested to select out pixel hue ranges to isolate color in HSV space. I understand HSV space, just not what these functions are doing to the arrays passed through them.

AbsDiffS

Calculates absolute difference between array and scalar

void cvAbsDiffS( const CvArr* A, CvArr* C, CvScalar S );

#define cvAbs(A, C) cvAbsDiffS(A, C, cvScalarAll(0))

A

The source array.

C

The destination array.

S

The scalar.

The function cvAbsDiffS calculates absolute difference between array and scalar.

C(I)c = abs(A(I)c - Sc).

All the arrays must have the same data type and the same size (or ROI size).

------------------

SubS

Computes difference of array and scalar

void cvSubS( const CvArr* A, CvScalar S, CvArr* C, const CvArr* mask=0 );

A

The source array.

S

Subed scalar.

C

The destination array.

mask

Operation mask, 8-bit single channel array; specifies elements of destination array to be changed.

The function cvSubS subtracts a scalar from every element of the source array:

C(I)=A(I)+S if mask(I)!=0

All the arrays must have the same type, except the mask, and the same size (or ROI size)

--------------------------

If I understood what calculations were being employed, I could pick the correct S scalar value to choose a hue range.

Help...

WLE

11 Comments

That means that each elemnt of the destination array is created by subtracting the scalar from the corresponding element (cotrresponding by index) in the source array. The same applies to the other function usind addition instead and a mask value.

cvAbsDiffS () returns an array that is a comparison of the pixels in the first array with a scalar value. The second array can then be scanned to easily find pixels that are within a couple of 'hues' of the original color.

cvSubS () does the same thing, but it returns a signed value. The second array can then be scanned to easily find pixels that have "at least" a specific hue.

Good Luck,

Kent

If I want to find all pixels in the Hue range of 110-118, for example, what would be my scalar value then for the absdiffs?

CvScalar s = CvScalar (110,118);

CvAbsDiffs(Image1, Image2, s);

Might this be how?

As for the LUT, I want to avoid iterating for the moment, it consumes time. I beleive the native cxcore matrix functions are faster.

Thanks WLE

110 is being subtracted from each pixel value - I am not sure where you would benefit from that.

>>As for the LUT, I want to avoid iterating for the moment

Um, that is a single function call, there is no iteration. -The idea was to zero-out all pixels that do not fall in the range of [110;118].

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**16** Experts available now in Live!