當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。