mirror of
https://github.com/opencv/opencv.git
synced 2024-12-14 08:59:11 +08:00
a03b813167
Fix OpenCV.js tests #25732 ### Pull Request Readiness Checklist * Firefox tests passed See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
|
|
QUnit.module('Core', {});
|
|
|
|
QUnit.test('test_LUT', function(assert) {
|
|
// test LUT
|
|
{
|
|
let src = cv.matFromArray(3, 3, cv.CV_8UC1, [255, 128, 0, 0, 128, 255, 1, 2, 254]);
|
|
let lutTable = [];
|
|
for (let i = 0; i < 256; i++)
|
|
{
|
|
lutTable[i] = 255 - i;
|
|
}
|
|
let lut = cv.matFromArray(1, 256, cv.CV_8UC1, lutTable);
|
|
let dst = new cv.Mat();
|
|
|
|
cv.LUT(src, lut, dst);
|
|
|
|
//console.log(dst.data);
|
|
assert.equal(dst.ucharAt(0), 0);
|
|
assert.equal(dst.ucharAt(1), 127);
|
|
assert.equal(dst.ucharAt(2), 255);
|
|
assert.equal(dst.ucharAt(3), 255);
|
|
assert.equal(dst.ucharAt(4), 127);
|
|
assert.equal(dst.ucharAt(5), 0);
|
|
assert.equal(dst.ucharAt(6), 254);
|
|
assert.equal(dst.ucharAt(7), 253);
|
|
assert.equal(dst.ucharAt(8), 1);
|
|
|
|
src.delete();
|
|
lut.delete();
|
|
dst.delete();
|
|
}
|
|
});
|