跳到主要内容

分割统计量 API

主要变更

  • 统计量计算从笔刷工具的方法中移出,改由一个专门的工具函数负责
  • 统计量现在使用 Web Worker 异步计算
  • 获取统计量的函数签名完全改变了
  • 计算过程中现在会派发进度事件

迁移步骤

1. 用独立工具函数替换基于工具的统计量方法

迁移前:

- const toolGroup = ToolGroupManager.getToolGroup(toolGroupId);
- const activeName = toolGroup.getActivePrimaryMouseButtonTool();
- const brush = toolGroup.getToolInstance(activeName);
- const stats = brush.getStatistics(viewport.element, { indices });

迁移后:

+ const stats = await segmentationUtils.getStatistics({
+ segmentationId,
+ segmentIndices: indices,
+ viewportId: viewport.id,
+ });
备注

需要传 viewportId,是因为有些统计量的计算与该视口中的基础影像有关。