当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript test.getTestImage函数代码示例

本文整理汇总了TypeScript中test.getTestImage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getTestImage函数的具体用法?TypeScript getTestImage怎么用?TypeScript getTestImage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getTestImage函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

test('write image to disk', async () => {
  const img = getTestImage();
  const destination = join(tmpDir, 'image.png');
  await write(destination, img);
  expect(existsSync(destination)).toBe(true);
  const imgRead = await read(destination);
  expect(imgRead).toStrictEqual(img);
});
开发者ID:image-js,项目名称:core,代码行数:8,代码来源:write.test.ts

示例2: it

  it('compare result of translation with opencv', () => {
    const img = getTestImage();
    const translation = [[1, 0, 2], [0, 1, 4]];
    const transformed = transform(img, translation, {
      width: 16,
      height: 20
    });

    const expected = readSync('test/img/testTranslation.png');
    expect(transformed.data).toStrictEqual(expected.data);
  });
开发者ID:image-js,项目名称:core,代码行数:11,代码来源:transform.test.ts

示例3: test

test('rotate + scale compared to opencv (nearest)', () => {
  const expected = readSync('test/img/testRotate.png');
  const img = getTestImage();
  const rotated = rotate(img, 30, {
    scale: 0.8,
    borderType: BorderType.REFLECT,
    interpolationType: InterpolationType.NEAREST,
    center: [2, 4]
  });

  expect(rotated.data).toStrictEqual(expected.data);
});
开发者ID:image-js,项目名称:core,代码行数:12,代码来源:rotate.test.ts

示例4: it

  it('blur compared to opencv', async () => {
    const img = getTestImage();

    const blurred = blur(img, {
      width: 3,
      height: 5,
      borderType: BorderType.REFLECT
    });

    const expected = await read('test/img/testBlur.png');
    expect(blurred.data).toStrictEqual(expected.data);
  });
开发者ID:image-js,项目名称:core,代码行数:12,代码来源:blur.test.ts

示例5: it

  it('direct convolution compared to opencv', async () => {
    const img = getTestImage();
    const kernelY = Matrix.columnVector([0.4, 0.5, 0.6, -0.3, -0.4]);
    const kernelX = Matrix.rowVector([0.1, 0.2, 0.3]);
    const kernel = kernelY.mmul(kernelX).to2DArray();

    const convoluted = directConvolution(img, kernel, {
      borderType: BorderType.REFLECT
    });

    const expected = await read('test/img/testConv.png');
    expect(convoluted.data).toStrictEqual(expected.data);
  });
开发者ID:image-js,项目名称:core,代码行数:13,代码来源:convolution.test.ts

示例6: async

  it.skip('gaussian blur should have same result as opencv', async () => {
    const img = getTestImage();
    const options = {
      borderType: BorderType.REFLECT,
      size: 3,
      sigmaX: 1,
      sigmaY: 1
    };
    const blurred = gaussianBlur(img, options);

    // const grey = convertColor(img, ImageKind.GREY);
    // const greyBlurred = gaussianBlur(grey, options);
    // console.log(greyBlurred.data);

    const expected = await read('test/img/testGaussianBlur.png');
    // write('gaussian.png', blurred);
    expect(expected.data).toStrictEqual(blurred.data);
  });
开发者ID:image-js,项目名称:core,代码行数:18,代码来源:gaussian.test.ts

示例7: 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);
});
开发者ID:image-js,项目名称:core,代码行数:20,代码来源:convertColor.test.ts

示例8: 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);
});
开发者ID:image-js,项目名称:core,代码行数:21,代码来源:threshold.test.ts


注:本文中的test.getTestImage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。