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


TypeScript test.getImage函数代码示例

本文整理汇总了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);
});
开发者ID:image-js,项目名称:core,代码行数:10,代码来源:histogram.test.ts

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

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

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

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


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