@labelwu/lb-utils
TypeScript icon, indicating that this package has built-in type declarations

1.14.0 • Public • Published

@labelwu/lb-utils

TODO: description

Usage

const lbUtils = require('@labelwu/lb-utils');

// TODO: DEMONSTRATE API

ToolStyleConverter

import { toolStyleConverter } from '@labelwu/lb-utils';

interface IToolStyle {
  stroke: string;
  fill: string;
}

const styleConfig = {
  borderOpacity: 1, // range: [0,1]
  fillOpacity: 0.2, // range: [0,1]
  colorIndex: 0, // range: 0 1 2 3 4 
};

// Basic Pattern
const result1 = {};
const rectConfig1 = {};

const data1: IToolStyle = toolStyleConverter.getColorFromConfig(
  result1
  rectConfig1,
  styleConfig,
);

// Attribute
const result2 = {
  attribute: 'value1',
};

const rectConfig2 = {
  attributeConfigurable: true,
  attributeList: [
    { key: 'key1', value: 'value1' },
    { key: 'key2', value: 'value2' },
  ]
};

const data2: IToolStyle = toolStyleConverter.getColorFromConfig(
  result2
  rectConfig2,
  styleConfig,
);

// MultiColor
const result3 = {};

const rectConfig3 = {};

const multiColorIndex = 0; // CurrentResultIndex

const data3: IToolStyle = toolStyleConverter.getColorFromConfig(
  result3
  rectConfig3,
  styleConfig,
  {
    multiColorIndex
  }
);

// invalid
const result4 = {
  valid: false
};
const rectConfig4 = {};

const data4: IToolStyle = toolStyleConverter.getColorFromConfig(
  result4
  rectConfig4,
  styleConfig,
);

// hover / selected
const result4 = {};
const rectConfig4 = {};

const status = {
  hover: true,
  // selected: true,
}

const data4: IToolStyle = toolStyleConverter.getColorFromConfig(
  result4
  rectConfig4,
  styleConfig,
  status
);

ImgConversionUtils

For picture conversion, providing input single channel mask output color picture

Quick Start

import { ImgConversionUtils } from '@labelwu/lb-utils';

const maskSrc = 'http://10.152.32.16:8080/ADE_val_00001993.png';
const basicImgSrc = 'http://10.152.32.16:8080/ADE_val_00001993.jpg';

/**
 * Convert mask to color map
 */
ImgConversionUtils.getColorMapBySingleChannelMask(
  maskSrc,
  basicImgSrc,
  
).then(newImg => {
  // Update your images
});

Show by labelbee

import React, { useEffect, useState } from 'react';
import { AnnotationView } from '@labelwu/lb-components';
import { ImgConversionUtils } from '@labelwu/lb-utils';

const maskSrc = 'http://10.152.32.16:8080/ADE_val_00001993.png';
const basicImgSrc = 'http://10.152.32.16:8080/ADE_val_00001993.jpg';

const App = () => {
  const [imgSrc, setImgSrc] = useState(maskSrc);
  useEffect(() => {
    ImgConversionUtils.getColorMapBySingleChannelMask({
      maskSrc,
      basicImgSrc,
    }).then((newSrc) => {
      setImgSrc(newSrc);
    });
  }, []);

  return (
    <div style={{ height: 1000 }}>
      <AnnotationView
        src={imgSrc}
      />
    </div>
  )
}

Other Props

interface ICustomColor {
    channel?: number;
    color?: string;
}

declare class ImgConversionUtils {
    static getColorMapBySingleChannelMask: (params: {
        maskSrc: string;
        basicImgSrc?: string | undefined;
        customColor?: ICustomColor[] | undefined; // You can customize the color of the specified channel value
        opacity?: number | undefined; // You can customize the opacity of your mask.
    }) => Promise<string | undefined>;
}
export default ImgConversionUtils;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.19.0-alpha.200alpha
1.14.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.19.0-alpha.200
1.19.0-alpha.190
1.19.0-alpha.180
1.19.0-alpha.170
1.19.0-alpha.160
1.19.0-alpha.150
1.19.0-alpha.140
1.19.0-alpha.130
1.19.0-alpha.120
1.19.0-alpha.110
1.19.0-alpha.100
1.19.0-alpha.20
1.19.0-alpha.10
1.14.00
1.13.00
1.12.00
1.11.00
1.10.00
1.9.01
1.8.00
1.7.00
1.7.0-alpha.30
1.7.0-alpha.10
1.6.00

Package Sidebar

Install

npm i @labelwu/lb-utils

Weekly Downloads

1

Version

1.14.0

License

Apache-2.0

Unpacked Size

208 kB

Total Files

42

Last publish

Collaborators

  • buket-wu