Boyko Perfanov
Boyko Perfanov

Reputation: 3047

cv::LUT() - what is the interpolation argument?

 void LUT(InputArray src, InputArray lut, OutputArray dst, int interpolation=0 )

makes a substitution in a 8-bit array, according to a look-up table, and stores the result in dst.

The opencv official documentation on the function is silent on the interpolation parameter. What is it used for and what values can be passed for it?

Upvotes: 2

Views: 1461

Answers (1)

Roger Rowland
Roger Rowland

Reputation: 26259

It seems to be redundant (or maybe reserved for some future expansion).

If you look at the implementation of that function, this is what you'll see (note the assertion in the second line of the function body!) :

void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst, int interpolation )
{
    Mat src = _src.getMat(), lut = _lut.getMat();
    CV_Assert( interpolation == 0 );
    int cn = src.channels();
    int lutcn = lut.channels();

    CV_Assert( (lutcn == cn || lutcn == 1) &&
        lut.total() == 256 && lut.isContinuous() &&
        (src.depth() == CV_8U || src.depth() == CV_8S) );
    _dst.create( src.dims, src.size, CV_MAKETYPE(lut.depth(), cn));
    Mat dst = _dst.getMat();

    LUTFunc func = lutTab[lut.depth()];
    CV_Assert( func != 0 );

    const Mat* arrays[] = {&src, &dst, 0};
    uchar* ptrs[2];
    NAryMatIterator it(arrays, ptrs);
    int len = (int)it.size;

    for( size_t i = 0; i < it.nplanes; i++, ++it )
        func(ptrs[0], lut.data, ptrs[1], len, cn, lutcn);
}

Upvotes: 7

Related Questions