本文整理汇总了TypeScript中test.getImage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getImage函数的具体用法?TypeScript getImage怎么用?TypeScript getImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getImage函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('RGBA image - channel 2', () => {
const image = getImage(
[[[230, 80, 120, 255]], [[100, 140, 120, 1]]],
ImageKind.RGBA
);
const histogram = image.histogram({ channel: 2 });
const expected = new Array(256).fill(0);
expected[120] = 2;
expect(histogram).toStrictEqual(expected);
});
示例2: it
it('Uint8 to Uint16', () => {
const img = getImage([[1, 2], [3, 4]], ImageKind.GREY, ColorDepth.UINT8);
const newImg = img.convertDepth(ColorDepth.UINT16);
expect(newImg.width).toStrictEqual(2);
expect(newImg.height).toStrictEqual(2);
expect(newImg.depth).toStrictEqual(ColorDepth.UINT16);
expect(newImg.kind).toStrictEqual(ImageKind.GREY);
expect(Array.from(newImg.data)).toStrictEqual([256, 512, 768, 1024]);
});
示例3: it
it('encoding a 16-bit image should convert it to a 8-bit image', () => {
const image = getImage(
[[256, 512], [768, 1024]],
ImageKind.GREY,
ColorDepth.UINT16
);
const encoded = encodeJpeg(image);
const reloaded = decode(encoded);
expect(reloaded.width).toStrictEqual(2);
expect(reloaded.height).toStrictEqual(2);
expect(reloaded.kind).toStrictEqual(ImageKind.RGBA);
expect(reloaded.depth).toStrictEqual(ColorDepth.UINT8);
});
示例4: test
test('test image to GREY', () => {
const testImage = getTestImage();
const grey = testImage.convertColor(ImageKind.GREY);
const expected = getImage(
[
[255, 255, 255, 255, 255, 255, 255, 255],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 76, 76, 255, 255, 179, 179, 0],
[0, 76, 76, 255, 255, 179, 179, 0],
[0, 150, 150, 0, 0, 105, 105, 0],
[0, 150, 150, 0, 0, 105, 105, 0],
[0, 29, 29, 128, 128, 226, 226, 0],
[0, 29, 29, 128, 128, 226, 226, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[255, 255, 255, 255, 255, 255, 255, 255]
],
ImageKind.GREY
);
expect(grey.data).toStrictEqual(expected.data);
});
示例5: test
test('automatic threshold with OTSU', () => {
const testImage = getTestImage();
const grey = testImage.convertColor(ImageKind.GREY);
const th = threshold(grey, { algorithm: ThresholdAlgorithm.OTSU });
const expected = getImage(
[
[255, 255, 255, 255, 255, 255, 255, 255],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 255, 255, 255, 255, 0],
[0, 0, 0, 255, 255, 255, 255, 0],
[0, 255, 255, 0, 0, 0, 0, 0],
[0, 255, 255, 0, 0, 0, 0, 0],
[0, 0, 0, 255, 255, 255, 255, 0],
[0, 0, 0, 255, 255, 255, 255, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[255, 255, 255, 255, 255, 255, 255, 255]
],
ImageKind.GREY
);
expect(th.data).toStrictEqual(expected.data);
});