@jax-data-science/sci-image-visualizer 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -460
- package/esm2022/index.mjs +28 -15
- package/esm2022/lib/channel-histogram/channel-histogram.component.mjs +163 -91
- package/esm2022/lib/contracts/capabilities.contract.mjs +4 -3
- package/esm2022/lib/contracts/cell-segmenter.contract.mjs +1 -1
- package/esm2022/lib/contracts/channel-histogram-api.contract.mjs +5 -1
- package/esm2022/lib/contracts/color.mjs +60 -0
- package/esm2022/lib/contracts/colormap-lut.mjs +213 -57
- package/esm2022/lib/contracts/coordinate-transform.contract.mjs +1 -1
- package/esm2022/lib/contracts/display-types.mjs +11 -1
- package/esm2022/lib/contracts/instance-segmenter.contract.mjs +1 -1
- package/esm2022/lib/contracts/intensity.mjs +48 -5
- package/esm2022/lib/contracts/plot-type-contribution.contract.mjs +1 -1
- package/esm2022/lib/contracts/plot-type.mjs +134 -17
- package/esm2022/lib/contracts/ports/image-state.port.mjs +4 -1
- package/esm2022/lib/contracts/ports/preferences.port.mjs +5 -1
- package/esm2022/lib/contracts/ports/region-io.port.mjs +2 -1
- package/esm2022/lib/contracts/ports/spatial-data.port.mjs +5 -1
- package/esm2022/lib/contracts/ports/tile-access.port.mjs +2 -1
- package/esm2022/lib/contracts/region-editor-api.contract.mjs +1 -1
- package/esm2022/lib/contracts/region-overlay.contract.mjs +1 -1
- package/esm2022/lib/contracts/sam.contract.mjs +1 -1
- package/esm2022/lib/contracts/semantic-segmenter.contract.mjs +1 -1
- package/esm2022/lib/contracts/spatial-dataset.contract.mjs +3 -1
- package/esm2022/lib/contracts/toolbar-tool.contract.mjs +6 -4
- package/esm2022/lib/contracts/visualizer.contract.mjs +1 -1
- package/esm2022/lib/contracts/viz-config.mjs +2 -1
- package/esm2022/lib/geometry/contour.mjs +63 -0
- package/esm2022/lib/geometry/raster.mjs +98 -0
- package/esm2022/lib/geometry/ring.mjs +201 -0
- package/esm2022/lib/hex-color-picker/hex-color-picker.component.mjs +202 -102
- package/esm2022/lib/implementations/base-store-visualizer.mjs +201 -48
- package/esm2022/lib/implementations/napari-js/napari-axes-gizmo.mjs +65 -0
- package/esm2022/lib/implementations/napari-js/napari-display-state.mjs +136 -0
- package/esm2022/lib/implementations/napari-js/napari-helpers.mjs +199 -0
- package/esm2022/lib/implementations/napari-js/napari-image-2d-scene.mjs +602 -0
- package/esm2022/lib/implementations/napari-js/napari-loading-badge.mjs +3 -4
- package/esm2022/lib/implementations/napari-js/napari-loading-state.mjs +66 -0
- package/esm2022/lib/implementations/napari-js/napari-region-overlay.mjs +157 -591
- package/esm2022/lib/implementations/napari-js/napari-scene.mjs +2 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-2d-scene.mjs +614 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-3d-scene.mjs +769 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-encoding.mjs +199 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-hover.mjs +263 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-scene.mjs +159 -0
- package/esm2022/lib/implementations/napari-js/napari-spatial-tiles.mjs +106 -1408
- package/esm2022/lib/implementations/napari-js/napari-spatial-tooltip.mjs +2 -2
- package/esm2022/lib/implementations/napari-js/napari-surface-scene.mjs +271 -0
- package/esm2022/lib/implementations/napari-js/napari-tile-client.mjs +562 -0
- package/esm2022/lib/implementations/napari-js/napari-tool-bridge.mjs +344 -0
- package/esm2022/lib/implementations/napari-js/napari-visualizer.service.mjs +361 -4184
- package/esm2022/lib/implementations/napari-js/napari-volume-scene.mjs +439 -0
- package/esm2022/lib/implementations/napari-js/napari-volume-z-handle.mjs +6 -6
- package/esm2022/lib/implementations/napari-js/region-overlay/overlay-projection.mjs +96 -0
- package/esm2022/lib/implementations/napari-js/region-overlay/region-edit.mjs +35 -0
- package/esm2022/lib/implementations/napari-js/region-overlay/region-svg-renderer.mjs +182 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/categorical-lookup.mjs +30 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/cell-layers.mjs +274 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/density-layer.mjs +144 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/layer-groups.mjs +165 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/plan-context.mjs +78 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-hover.mjs +182 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-jobs.mjs +369 -0
- package/esm2022/lib/implementations/napari-js/spatial-tiles/transcript-layers.mjs +306 -0
- package/esm2022/lib/implementations/osd/display-pipeline.mjs +102 -40
- package/esm2022/lib/implementations/osd/histogram-sampler.mjs +56 -31
- package/esm2022/lib/implementations/osd/openseadragon-viewer-options.mjs +128 -0
- package/esm2022/lib/implementations/osd/openseadragon-visualizer.service.mjs +333 -1685
- package/esm2022/lib/implementations/osd/osd-coordinate-transform.mjs +1 -1
- package/esm2022/lib/implementations/osd/osd-coords.mjs +5 -6
- package/esm2022/lib/implementations/osd/osd-export.mjs +122 -0
- package/esm2022/lib/implementations/osd/osd-lib.mjs +15 -1
- package/esm2022/lib/implementations/osd/osd-navigator-chrome.mjs +205 -0
- package/esm2022/lib/implementations/osd/osd-pixel-readback.mjs +68 -0
- package/esm2022/lib/implementations/osd/osd-region-overlay-draw.mjs +153 -0
- package/esm2022/lib/implementations/osd/osd-region-overlay.mjs +185 -718
- package/esm2022/lib/implementations/osd/osd-scale-bar.mjs +52 -60
- package/esm2022/lib/implementations/osd/osd-tile-source.mjs +105 -0
- package/esm2022/lib/implementations/osd/osd-viewer-like.mjs +2 -0
- package/esm2022/lib/implementations/osd/osd-viewer-mount.mjs +44 -0
- package/esm2022/lib/implementations/osd/osd-viewport.mjs +184 -0
- package/esm2022/lib/implementations/osd/osd-zoom.mjs +7 -1
- package/esm2022/lib/implementations/osd/simple-source.mjs +395 -0
- package/esm2022/lib/implementations/osd/slice-cache.mjs +53 -48
- package/esm2022/lib/implementations/osd/tile-client.mjs +32 -11
- package/esm2022/lib/implementations/osd/tile-recolor.mjs +330 -0
- package/esm2022/lib/implementations/plotly/omics-trace-builders.mjs +161 -73
- package/esm2022/lib/implementations/plotly/plotly-coordinate-transform.mjs +1 -1
- package/esm2022/lib/implementations/plotly/plotly-image-loader.mjs +112 -0
- package/esm2022/lib/implementations/plotly/plotly-image-recolor.mjs +178 -0
- package/esm2022/lib/implementations/plotly/plotly-intensity-inset.mjs +33 -0
- package/esm2022/lib/implementations/plotly/plotly-isosurface-controls.mjs +83 -0
- package/esm2022/lib/implementations/plotly/plotly-layouts.mjs +121 -0
- package/esm2022/lib/implementations/plotly/plotly-readback.mjs +117 -0
- package/esm2022/lib/implementations/plotly/plotly-region-overlay.mjs +19 -10
- package/esm2022/lib/implementations/plotly/plotly-shape-projection.mjs +223 -0
- package/esm2022/lib/implementations/plotly/plotly-trace-builders.mjs +79 -19
- package/esm2022/lib/implementations/plotly/plotly-zoom-controller.mjs +223 -0
- package/esm2022/lib/implementations/plotly/plotly.service.mjs +439 -1655
- package/esm2022/lib/implementations/region-centroids.mjs +47 -0
- package/esm2022/lib/implementations/simple-slice-access.service.mjs +22 -12
- package/esm2022/lib/implementations/spatial-data-http/spatial-data-http.service.mjs +172 -92
- package/esm2022/lib/implementations/spatial-data-http/spatial-wire.mjs +103 -22
- package/esm2022/lib/implementations/tile-server/index.mjs +6 -0
- package/esm2022/lib/implementations/tile-server/native-histogram.mjs +30 -0
- package/esm2022/lib/implementations/tile-server/poll-descriptor.mjs +65 -0
- package/esm2022/lib/implementations/tile-server/tile-protocol.mjs +42 -0
- package/esm2022/lib/implementations/tile-server/transport.mjs +135 -0
- package/esm2022/lib/intensity/intensity-profile.mjs +107 -0
- package/esm2022/lib/intensity/intensity-profile.service.mjs +223 -0
- package/esm2022/lib/intensity-inset/intensity-inset.component.mjs +133 -0
- package/esm2022/lib/models/bezier.mjs +1 -11
- package/esm2022/lib/models/class-preset.mjs +41 -3
- package/esm2022/lib/models/geometry.mjs +27 -164
- package/esm2022/lib/models/polygon-edit.mjs +254 -0
- package/esm2022/lib/models/polygon-factory.mjs +118 -0
- package/esm2022/lib/models/region-clone.mjs +68 -0
- package/esm2022/lib/models/region-geojson.mjs +373 -0
- package/esm2022/lib/models/region.mjs +34 -33
- package/esm2022/lib/models/shape.mjs +18 -16
- package/esm2022/lib/plot-mode/contribution-host.mjs +297 -0
- package/esm2022/lib/plot-mode/plot-mode-controller.mjs +9 -6
- package/esm2022/lib/plot-mode/plot-type-menu.mjs +85 -0
- package/esm2022/lib/plot-mode/tool-params-model.mjs +87 -0
- package/esm2022/lib/plot.utilities.mjs +296 -473
- package/esm2022/lib/processing/image-crop.mjs +1 -1
- package/esm2022/lib/processing/processing-image.mjs +28 -15
- package/esm2022/lib/provide-visualization.mjs +40 -14
- package/esm2022/lib/region-editor/classes-panel/classes-panel.component.mjs +99 -0
- package/esm2022/lib/region-editor/file-stem.mjs +13 -0
- package/esm2022/lib/region-editor/manage-classes-dialog/manage-classes-dialog.component.mjs +118 -0
- package/esm2022/lib/region-editor/mask-export.service.mjs +98 -0
- package/esm2022/lib/region-editor/mask-raster.mjs +11 -5
- package/esm2022/lib/region-editor/region-color-dialog/region-color-dialog.component.mjs +56 -0
- package/esm2022/lib/region-editor/region-editor-help/region-editor-help.component.mjs +28 -0
- package/esm2022/lib/region-editor/region-editor.component.mjs +402 -651
- package/esm2022/lib/region-editor/region-metrics.mjs +68 -0
- package/esm2022/lib/region-editor/region-persistence.service.mjs +134 -0
- package/esm2022/lib/region-editor/region-table/region-table.component.mjs +153 -0
- package/esm2022/lib/region-editor/save-mask-dialog/save-mask-dialog.component.mjs +91 -0
- package/esm2022/lib/region-editor/save-regions-dialog/save-regions-dialog.component.mjs +92 -0
- package/esm2022/lib/region-ops.service.mjs +28 -70
- package/esm2022/lib/region-overlay/region-geometry.mjs +360 -0
- package/esm2022/lib/region-overlay/region-hit-test.mjs +103 -0
- package/esm2022/lib/region-overlay/svg-region-renderer.mjs +228 -0
- package/esm2022/lib/render-orchestrator.mjs +14 -11
- package/esm2022/lib/render-session.mjs +207 -0
- package/esm2022/lib/routing-visualizer.service.mjs +459 -411
- package/esm2022/lib/spatial/density-raster.mjs +14 -0
- package/esm2022/lib/spatial/embedding-compute-coordinator.mjs +239 -0
- package/esm2022/lib/spatial/embedding-compute.mjs +43 -10
- package/esm2022/lib/spatial/gene-search.mjs +1 -1
- package/esm2022/lib/spatial/glyphs.mjs +97 -0
- package/esm2022/lib/spatial/lod.mjs +187 -0
- package/esm2022/lib/spatial/spatial-controls.facade.mjs +200 -0
- package/esm2022/lib/spatial/spatial-density.mjs +25 -16
- package/esm2022/lib/spatial/spatial-encoding.mjs +26 -82
- package/esm2022/lib/spatial/spatial-expression.mjs +43 -42
- package/esm2022/lib/spatial/spatial-framing.mjs +1 -1
- package/esm2022/lib/spatial/spatial-heatmap.mjs +6 -3
- package/esm2022/lib/spatial/spatial-hover.mjs +5 -33
- package/esm2022/lib/spatial/spatial-panel-model.mjs +282 -0
- package/esm2022/lib/spatial/spatial-sections.mjs +1 -1
- package/esm2022/lib/spatial/spatial-selection.mjs +33 -46
- package/esm2022/lib/spatial/spatial-tile-merge.mjs +219 -0
- package/esm2022/lib/spatial/spatial-tiles.mjs +12 -648
- package/esm2022/lib/spatial/spatial-volume-image.mjs +2 -4
- package/esm2022/lib/spatial/stats.mjs +71 -0
- package/esm2022/lib/spatial/transcript-grouping.mjs +307 -0
- package/esm2022/lib/spatial-controls/spatial-cells-panel/spatial-cells-panel.component.mjs +150 -0
- package/esm2022/lib/spatial-controls/spatial-charts/chart-data-model.mjs +309 -0
- package/esm2022/lib/spatial-controls/spatial-charts/chart-help.mjs +145 -0
- package/esm2022/lib/spatial-controls/spatial-charts/plotly-chart-host.mjs +158 -0
- package/esm2022/lib/spatial-controls/spatial-charts/spatial-chart-window/spatial-chart-window.component.mjs +47 -0
- package/esm2022/lib/spatial-controls/spatial-charts/spatial-charts.component.mjs +297 -802
- package/esm2022/lib/spatial-controls/spatial-charts/spatial-embedding-controls/spatial-embedding-controls.component.mjs +89 -0
- package/esm2022/lib/spatial-controls/spatial-charts/spatial-heatmap-controls/spatial-heatmap-controls.component.mjs +52 -0
- package/esm2022/lib/spatial-controls/spatial-controls.component.mjs +143 -1238
- package/esm2022/lib/spatial-controls/spatial-gene-picker.mjs +153 -0
- package/esm2022/lib/spatial-controls/spatial-gene-tree/spatial-gene-tree.component.mjs +241 -0
- package/esm2022/lib/spatial-controls/spatial-groups-panel/spatial-groups-panel.component.mjs +193 -0
- package/esm2022/lib/spatial-controls/spatial-key/spatial-key.component.mjs +132 -0
- package/esm2022/lib/spatial-controls/spatial-key/spatial-key.model.mjs +67 -0
- package/esm2022/lib/spatial-controls/spatial-marker-genes-form/spatial-marker-genes-form.component.mjs +147 -0
- package/esm2022/lib/spatial-controls/spatial-observations-panel/spatial-observations-panel.component.mjs +300 -0
- package/esm2022/lib/spatial-controls/spatial-transcripts-panel/spatial-transcripts-panel.component.mjs +370 -0
- package/esm2022/lib/store/class-color.util.mjs +46 -3
- package/esm2022/lib/store/region-history.mjs +146 -0
- package/esm2022/lib/store/region-scope-cache.mjs +140 -0
- package/esm2022/lib/store/region-selection.mjs +82 -0
- package/esm2022/lib/store/region-store.service.mjs +279 -675
- package/esm2022/lib/store/spatial-selection.service.mjs +2 -2
- package/esm2022/lib/store/visualizer-store.service.mjs +49 -71
- package/esm2022/lib/toast-outlets.mjs +5 -4
- package/esm2022/lib/toolbar/brush/brush-tool.service.mjs +92 -434
- package/esm2022/lib/toolbar/canvas-tools.mjs +20 -0
- package/esm2022/lib/toolbar/crop/slide-crop.mjs +26 -42
- package/esm2022/lib/toolbar/plot-type-selector/plot-type-selector.component.mjs +85 -0
- package/esm2022/lib/toolbar/region-tools/region-tool-buttons.mjs +74 -0
- package/esm2022/lib/toolbar/region-tools/region-tools.component.mjs +114 -0
- package/esm2022/lib/toolbar/segmentation/cell-segment-tool.service.mjs +74 -78
- package/esm2022/lib/toolbar/segmentation/cellpose-segmenter.service.mjs +50 -8
- package/esm2022/lib/toolbar/segmentation/onnx-sam-session.mjs +61 -42
- package/esm2022/lib/toolbar/segmentation/pending-calls.mjs +47 -0
- package/esm2022/lib/toolbar/segmentation/sam-model-registry.mjs +12 -4
- package/esm2022/lib/toolbar/segmentation/sam-onnx-core.mjs +70 -14
- package/esm2022/lib/toolbar/segmentation/sam-point-tool.service.mjs +135 -172
- package/esm2022/lib/toolbar/segmentation/sam-prompt.mjs +9 -90
- package/esm2022/lib/toolbar/segmentation/sam-session.service.mjs +183 -0
- package/esm2022/lib/toolbar/segmentation/sam-tool.service.mjs +95 -150
- package/esm2022/lib/toolbar/segmentation/segmentation-commit.mjs +12 -0
- package/esm2022/lib/toolbar/segmentation/segmentation-runner.mjs +108 -0
- package/esm2022/lib/toolbar/segmentation-tools/segmentation-tools.component.mjs +155 -0
- package/esm2022/lib/toolbar/stack-controls/stack-controls.component.mjs +81 -0
- package/esm2022/lib/toolbar/tool-kit/async-tool-status.mjs +37 -0
- package/esm2022/lib/toolbar/tool-kit/canvas-tool-manager.mjs +63 -0
- package/esm2022/lib/toolbar/tool-kit/canvas-tool.mjs +2 -0
- package/esm2022/lib/toolbar/tool-kit/frame-pixels.mjs +108 -0
- package/esm2022/lib/toolbar/tool-kit/mask-stroke-editor.mjs +306 -0
- package/esm2022/lib/toolbar/tool-kit/matrix-frame.mjs +61 -0
- package/esm2022/lib/toolbar/tool-kit/tool-overlay.mjs +140 -0
- package/esm2022/lib/toolbar/tool-kit/undo-gesture.mjs +24 -0
- package/esm2022/lib/toolbar/tool-slider/tool-slider.component.mjs +63 -0
- package/esm2022/lib/toolbar/toolbar-help-dialog/toolbar-help-dialog.component.mjs +50 -0
- package/esm2022/lib/toolbar/toolbar.component.mjs +68 -117
- package/esm2022/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.mjs +93 -115
- package/esm2022/lib/toolbar/view-controls/view-controls.component.mjs +107 -0
- package/esm2022/lib/toolbar/wand/wand-region-grow.mjs +321 -0
- package/esm2022/lib/toolbar/wand/wand-tool.service.mjs +121 -416
- package/esm2022/lib/toolbar/wand/wand.service.mjs +30 -894
- package/esm2022/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.mjs +48 -90
- package/esm2022/lib/util/mark-for-check.mjs +17 -0
- package/esm2022/lib/util/supersede.mjs +56 -0
- package/esm2022/lib/visualization.module.mjs +39 -141
- package/esm2022/lib/visualizer/floating-drag.directive.mjs +58 -0
- package/esm2022/lib/visualizer/region-actions.mjs +149 -0
- package/esm2022/lib/visualizer/region-load.mjs +60 -0
- package/esm2022/lib/visualizer/spatial-dataset-binder.mjs +163 -0
- package/esm2022/lib/visualizer/tool-modes.mjs +113 -0
- package/esm2022/lib/visualizer/viewer-shortcuts.mjs +167 -0
- package/esm2022/lib/visualizer/visualizer-context-menu.mjs +119 -0
- package/esm2022/lib/visualizer.component.mjs +480 -1902
- package/esm2022/lib/workers/spatial-math-ops.mjs +43 -0
- package/esm2022/lib/workers/spatial-math-worker.mjs +10 -0
- package/esm2022/lib/workers/spatial-math.mjs +190 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-jax-data-science-sci-image-visualizer-Csxlnq7I.mjs +41083 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-jax-data-science-sci-image-visualizer-Csxlnq7I.mjs.map +1 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-Bkujqg7m.mjs +238 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-Bkujqg7m.mjs.map +1 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-spatial-math-worker-BzVFFqGS.mjs +12 -0
- package/fesm2022/jax-data-science-sci-image-visualizer-spatial-math-worker-BzVFFqGS.mjs.map +1 -0
- package/fesm2022/jax-data-science-sci-image-visualizer.mjs +41 -34430
- package/fesm2022/jax-data-science-sci-image-visualizer.mjs.map +1 -1
- package/fesm2022/mask.worker.js +36 -917
- package/fesm2022/onnx-sam.worker.js +52 -16
- package/fesm2022/spatial-math.worker.js +471 -0
- package/fesm2022/tsne.worker.js +32 -15
- package/index.d.ts +13 -10
- package/lib/channel-histogram/channel-histogram.component.d.ts +53 -43
- package/lib/contracts/capabilities.contract.d.ts +4 -2
- package/lib/contracts/cell-segmenter.contract.d.ts +1 -0
- package/lib/contracts/channel-histogram-api.contract.d.ts +4 -0
- package/lib/contracts/color.d.ts +27 -0
- package/lib/contracts/colormap-lut.d.ts +19 -4
- package/lib/contracts/coordinate-transform.contract.d.ts +3 -3
- package/lib/contracts/display-types.d.ts +21 -0
- package/lib/contracts/instance-segmenter.contract.d.ts +5 -0
- package/lib/contracts/intensity.d.ts +13 -2
- package/lib/contracts/plot-type.d.ts +3 -1
- package/lib/contracts/ports/image-state.port.d.ts +6 -2
- package/lib/contracts/ports/preferences.port.d.ts +4 -0
- package/lib/contracts/ports/region-io.port.d.ts +1 -0
- package/lib/contracts/ports/spatial-data.port.d.ts +4 -10
- package/lib/contracts/ports/tile-access.port.d.ts +1 -0
- package/lib/contracts/region-editor-api.contract.d.ts +1 -1
- package/lib/contracts/region-overlay.contract.d.ts +5 -0
- package/lib/contracts/sam.contract.d.ts +7 -0
- package/lib/contracts/semantic-segmenter.contract.d.ts +6 -0
- package/lib/contracts/spatial-dataset.contract.d.ts +19 -6
- package/lib/contracts/toolbar-tool.contract.d.ts +1 -0
- package/lib/contracts/visualizer.contract.d.ts +221 -54
- package/lib/contracts/viz-config.d.ts +1 -0
- package/lib/geometry/contour.d.ts +24 -0
- package/lib/geometry/raster.d.ts +42 -0
- package/lib/geometry/ring.d.ts +67 -0
- package/lib/hex-color-picker/hex-color-picker.component.d.ts +61 -27
- package/lib/implementations/base-store-visualizer.d.ts +61 -15
- package/lib/implementations/napari-js/napari-axes-gizmo.d.ts +36 -0
- package/lib/implementations/napari-js/napari-display-state.d.ts +76 -0
- package/lib/implementations/napari-js/napari-helpers.d.ts +129 -0
- package/lib/implementations/napari-js/napari-image-2d-scene.d.ts +162 -0
- package/lib/implementations/napari-js/napari-loading-badge.d.ts +0 -1
- package/lib/implementations/napari-js/napari-loading-state.d.ts +30 -0
- package/lib/implementations/napari-js/napari-region-overlay.d.ts +62 -70
- package/lib/implementations/napari-js/napari-scene.d.ts +93 -0
- package/lib/implementations/napari-js/napari-spatial-2d-scene.d.ts +163 -0
- package/lib/implementations/napari-js/napari-spatial-3d-scene.d.ts +212 -0
- package/lib/implementations/napari-js/napari-spatial-encoding.d.ts +114 -0
- package/lib/implementations/napari-js/napari-spatial-hover.d.ts +89 -0
- package/lib/implementations/napari-js/napari-spatial-scene.d.ts +118 -0
- package/lib/implementations/napari-js/napari-spatial-tiles.d.ts +56 -263
- package/lib/implementations/napari-js/napari-spatial-tooltip.d.ts +1 -1
- package/lib/implementations/napari-js/napari-surface-scene.d.ts +76 -0
- package/lib/implementations/napari-js/napari-tile-client.d.ts +214 -0
- package/lib/implementations/napari-js/napari-tool-bridge.d.ts +179 -0
- package/lib/implementations/napari-js/napari-visualizer.service.d.ts +121 -878
- package/lib/implementations/napari-js/napari-volume-scene.d.ts +104 -0
- package/lib/implementations/napari-js/napari-volume-z-handle.d.ts +8 -12
- package/lib/implementations/napari-js/region-overlay/overlay-projection.d.ts +59 -0
- package/lib/implementations/napari-js/region-overlay/region-edit.d.ts +15 -0
- package/lib/implementations/napari-js/region-overlay/region-svg-renderer.d.ts +54 -0
- package/lib/implementations/napari-js/spatial-tiles/categorical-lookup.d.ts +26 -0
- package/lib/implementations/napari-js/spatial-tiles/cell-layers.d.ts +70 -0
- package/lib/implementations/napari-js/spatial-tiles/density-layer.d.ts +61 -0
- package/lib/implementations/napari-js/spatial-tiles/layer-groups.d.ts +67 -0
- package/lib/implementations/napari-js/spatial-tiles/plan-context.d.ts +38 -0
- package/lib/implementations/napari-js/spatial-tiles/transcript-hover.d.ts +71 -0
- package/lib/implementations/napari-js/spatial-tiles/transcript-jobs.d.ts +105 -0
- package/lib/implementations/napari-js/spatial-tiles/transcript-layers.d.ts +56 -0
- package/lib/implementations/osd/display-pipeline.d.ts +38 -9
- package/lib/implementations/osd/histogram-sampler.d.ts +22 -12
- package/lib/implementations/osd/openseadragon-viewer-options.d.ts +35 -0
- package/lib/implementations/osd/openseadragon-visualizer.service.d.ts +78 -354
- package/lib/implementations/osd/osd-coordinate-transform.d.ts +2 -1
- package/lib/implementations/osd/osd-coords.d.ts +6 -4
- package/lib/implementations/osd/osd-export.d.ts +36 -0
- package/lib/implementations/osd/osd-lib.d.ts +7 -0
- package/lib/implementations/osd/osd-navigator-chrome.d.ts +69 -0
- package/lib/implementations/osd/osd-pixel-readback.d.ts +22 -0
- package/lib/implementations/osd/osd-region-overlay-draw.d.ts +37 -0
- package/lib/implementations/osd/osd-region-overlay.d.ts +36 -48
- package/lib/implementations/osd/osd-scale-bar.d.ts +8 -6
- package/lib/implementations/osd/osd-tile-source.d.ts +49 -0
- package/lib/implementations/osd/osd-viewer-like.d.ts +100 -0
- package/lib/implementations/osd/osd-viewer-mount.d.ts +14 -0
- package/lib/implementations/osd/osd-viewport.d.ts +77 -0
- package/lib/implementations/osd/osd-zoom.d.ts +6 -0
- package/lib/implementations/osd/simple-source.d.ts +161 -0
- package/lib/implementations/osd/slice-cache.d.ts +12 -3
- package/lib/implementations/osd/tile-client.d.ts +11 -14
- package/lib/implementations/osd/tile-recolor.d.ts +141 -0
- package/lib/implementations/plotly/omics-trace-builders.d.ts +32 -20
- package/lib/implementations/plotly/plotly-image-loader.d.ts +49 -0
- package/lib/implementations/plotly/plotly-image-recolor.d.ts +75 -0
- package/lib/implementations/plotly/plotly-intensity-inset.d.ts +8 -0
- package/lib/implementations/plotly/plotly-isosurface-controls.d.ts +38 -0
- package/lib/implementations/plotly/plotly-layouts.d.ts +188 -0
- package/lib/implementations/plotly/plotly-readback.d.ts +41 -0
- package/lib/implementations/plotly/plotly-region-overlay.d.ts +2 -2
- package/lib/implementations/plotly/plotly-shape-projection.d.ts +92 -0
- package/lib/implementations/plotly/plotly-trace-builders.d.ts +23 -12
- package/lib/implementations/plotly/plotly-zoom-controller.d.ts +86 -0
- package/lib/implementations/plotly/plotly.service.d.ts +136 -401
- package/lib/implementations/region-centroids.d.ts +14 -0
- package/lib/implementations/simple-slice-access.service.d.ts +7 -4
- package/lib/implementations/spatial-data-http/spatial-data-http.service.d.ts +42 -18
- package/lib/implementations/spatial-data-http/spatial-wire.d.ts +34 -9
- package/lib/implementations/tile-server/index.d.ts +5 -0
- package/lib/implementations/tile-server/native-histogram.d.ts +25 -0
- package/lib/implementations/tile-server/poll-descriptor.d.ts +39 -0
- package/lib/implementations/tile-server/tile-protocol.d.ts +80 -0
- package/lib/implementations/tile-server/transport.d.ts +62 -0
- package/lib/intensity/intensity-profile.d.ts +66 -0
- package/lib/intensity/intensity-profile.service.d.ts +108 -0
- package/lib/intensity-inset/intensity-inset.component.d.ts +58 -0
- package/lib/models/bezier.d.ts +0 -5
- package/lib/models/class-preset.d.ts +18 -0
- package/lib/models/geometry.d.ts +14 -48
- package/lib/models/polygon-edit.d.ts +72 -0
- package/lib/models/polygon-factory.d.ts +40 -0
- package/lib/models/region-clone.d.ts +20 -0
- package/lib/models/region-geojson.d.ts +17 -0
- package/lib/models/region.d.ts +40 -4
- package/lib/models/shape.d.ts +8 -0
- package/lib/plot-mode/contribution-host.d.ts +125 -0
- package/lib/plot-mode/plot-type-menu.d.ts +60 -0
- package/lib/plot-mode/tool-params-model.d.ts +49 -0
- package/lib/plot.utilities.d.ts +19 -30
- package/lib/processing/processing-image.d.ts +5 -2
- package/lib/provide-visualization.d.ts +19 -2
- package/lib/region-editor/classes-panel/classes-panel.component.d.ts +56 -0
- package/lib/region-editor/file-stem.d.ts +7 -0
- package/lib/region-editor/manage-classes-dialog/manage-classes-dialog.component.d.ts +45 -0
- package/lib/region-editor/mask-export.service.d.ts +54 -0
- package/lib/region-editor/mask-raster.d.ts +2 -8
- package/lib/region-editor/region-color-dialog/region-color-dialog.component.d.ts +29 -0
- package/lib/region-editor/region-editor-help/region-editor-help.component.d.ts +11 -0
- package/lib/region-editor/region-editor.component.d.ts +166 -199
- package/lib/region-editor/region-metrics.d.ts +26 -0
- package/lib/region-editor/region-persistence.service.d.ts +69 -0
- package/lib/region-editor/region-table/region-table.component.d.ts +83 -0
- package/lib/region-editor/save-mask-dialog/save-mask-dialog.component.d.ts +36 -0
- package/lib/region-editor/save-regions-dialog/save-regions-dialog.component.d.ts +37 -0
- package/lib/region-ops.service.d.ts +1 -7
- package/lib/region-overlay/region-geometry.d.ts +157 -0
- package/lib/region-overlay/region-hit-test.d.ts +38 -0
- package/lib/region-overlay/svg-region-renderer.d.ts +110 -0
- package/lib/render-orchestrator.d.ts +6 -2
- package/lib/render-session.d.ts +75 -0
- package/lib/routing-visualizer.service.d.ts +110 -58
- package/lib/spatial/density-raster.d.ts +6 -0
- package/lib/spatial/embedding-compute-coordinator.d.ts +123 -0
- package/lib/spatial/embedding-compute.d.ts +21 -2
- package/lib/spatial/glyphs.d.ts +16 -0
- package/lib/spatial/lod.d.ts +94 -0
- package/lib/spatial/spatial-controls.facade.d.ts +64 -0
- package/lib/spatial/spatial-density.d.ts +15 -5
- package/lib/spatial/spatial-encoding.d.ts +11 -44
- package/lib/spatial/spatial-expression.d.ts +40 -22
- package/lib/spatial/spatial-framing.d.ts +1 -0
- package/lib/spatial/spatial-heatmap.d.ts +2 -0
- package/lib/spatial/spatial-hover.d.ts +4 -16
- package/lib/spatial/spatial-panel-model.d.ts +135 -0
- package/lib/spatial/spatial-selection.d.ts +21 -26
- package/lib/spatial/spatial-tile-merge.d.ts +41 -0
- package/lib/spatial/spatial-tiles.d.ts +9 -256
- package/lib/spatial/stats.d.ts +38 -0
- package/lib/spatial/transcript-grouping.d.ts +119 -0
- package/lib/spatial-controls/spatial-cells-panel/spatial-cells-panel.component.d.ts +64 -0
- package/lib/spatial-controls/spatial-charts/chart-data-model.d.ts +153 -0
- package/lib/spatial-controls/spatial-charts/chart-help.d.ts +69 -0
- package/lib/spatial-controls/spatial-charts/plotly-chart-host.d.ts +98 -0
- package/lib/spatial-controls/spatial-charts/spatial-chart-window/spatial-chart-window.component.d.ts +26 -0
- package/lib/spatial-controls/spatial-charts/spatial-charts.component.d.ts +101 -260
- package/lib/spatial-controls/spatial-charts/spatial-embedding-controls/spatial-embedding-controls.component.d.ts +43 -0
- package/lib/spatial-controls/spatial-charts/spatial-heatmap-controls/spatial-heatmap-controls.component.d.ts +27 -0
- package/lib/spatial-controls/spatial-controls.component.d.ts +68 -448
- package/lib/spatial-controls/spatial-gene-picker.d.ts +86 -0
- package/lib/spatial-controls/spatial-gene-tree/spatial-gene-tree.component.d.ts +102 -0
- package/lib/spatial-controls/spatial-groups-panel/spatial-groups-panel.component.d.ts +72 -0
- package/lib/spatial-controls/spatial-key/spatial-key.component.d.ts +66 -0
- package/lib/spatial-controls/spatial-key/spatial-key.model.d.ts +33 -0
- package/lib/spatial-controls/spatial-marker-genes-form/spatial-marker-genes-form.component.d.ts +64 -0
- package/lib/spatial-controls/spatial-observations-panel/spatial-observations-panel.component.d.ts +117 -0
- package/lib/spatial-controls/spatial-transcripts-panel/spatial-transcripts-panel.component.d.ts +142 -0
- package/lib/store/class-color.util.d.ts +35 -1
- package/lib/store/region-history.d.ts +66 -0
- package/lib/store/region-scope-cache.d.ts +63 -0
- package/lib/store/region-selection.d.ts +36 -0
- package/lib/store/region-store.service.d.ts +104 -112
- package/lib/store/visualizer-store.service.d.ts +22 -33
- package/lib/toast-outlets.d.ts +4 -3
- package/lib/toolbar/brush/brush-tool.service.d.ts +31 -98
- package/lib/toolbar/canvas-tools.d.ts +20 -0
- package/lib/toolbar/crop/slide-crop.d.ts +10 -4
- package/lib/toolbar/plot-type-selector/plot-type-selector.component.d.ts +38 -0
- package/lib/toolbar/region-tools/region-tool-buttons.d.ts +21 -0
- package/lib/toolbar/region-tools/region-tools.component.d.ts +60 -0
- package/lib/toolbar/segmentation/cell-segment-tool.service.d.ts +10 -14
- package/lib/toolbar/segmentation/cellpose-segmenter.service.d.ts +12 -2
- package/lib/toolbar/segmentation/onnx-sam-session.d.ts +22 -3
- package/lib/toolbar/segmentation/pending-calls.d.ts +31 -0
- package/lib/toolbar/segmentation/sam-model-registry.d.ts +9 -3
- package/lib/toolbar/segmentation/sam-onnx-core.d.ts +18 -5
- package/lib/toolbar/segmentation/sam-point-tool.service.d.ts +46 -32
- package/lib/toolbar/segmentation/sam-prompt.d.ts +7 -31
- package/lib/toolbar/segmentation/sam-session.service.d.ts +74 -0
- package/lib/toolbar/segmentation/sam-tool.service.d.ts +23 -30
- package/lib/toolbar/segmentation/segmentation-commit.d.ts +8 -0
- package/lib/toolbar/segmentation/segmentation-runner.d.ts +52 -0
- package/lib/toolbar/segmentation-tools/segmentation-tools.component.d.ts +87 -0
- package/lib/toolbar/stack-controls/stack-controls.component.d.ts +40 -0
- package/lib/toolbar/tool-kit/async-tool-status.d.ts +21 -0
- package/lib/toolbar/tool-kit/canvas-tool-manager.d.ts +36 -0
- package/lib/toolbar/tool-kit/canvas-tool.d.ts +86 -0
- package/lib/toolbar/tool-kit/frame-pixels.d.ts +45 -0
- package/lib/toolbar/tool-kit/mask-stroke-editor.d.ts +125 -0
- package/lib/toolbar/tool-kit/matrix-frame.d.ts +40 -0
- package/lib/toolbar/tool-kit/tool-overlay.d.ts +60 -0
- package/lib/toolbar/tool-kit/undo-gesture.d.ts +17 -0
- package/lib/toolbar/tool-slider/tool-slider.component.d.ts +33 -0
- package/lib/toolbar/toolbar-help-dialog/toolbar-help-dialog.component.d.ts +24 -0
- package/lib/toolbar/toolbar.component.d.ts +47 -83
- package/lib/toolbar/vertex-eraser/vertex-eraser-tool.service.d.ts +33 -40
- package/lib/toolbar/view-controls/view-controls.component.d.ts +54 -0
- package/lib/toolbar/wand/wand-region-grow.d.ts +49 -0
- package/lib/toolbar/wand/wand-tool.service.d.ts +39 -124
- package/lib/toolbar/wand/wand.service.d.ts +22 -116
- package/lib/toolbar/zoom-to-box/zoom-to-box-tool.service.d.ts +17 -37
- package/lib/util/mark-for-check.d.ts +11 -0
- package/lib/util/supersede.d.ts +53 -0
- package/lib/visualization.module.d.ts +18 -39
- package/lib/visualizer/floating-drag.directive.d.ts +30 -0
- package/lib/visualizer/region-actions.d.ts +54 -0
- package/lib/visualizer/region-load.d.ts +27 -0
- package/lib/visualizer/spatial-dataset-binder.d.ts +74 -0
- package/lib/visualizer/tool-modes.d.ts +49 -0
- package/lib/visualizer/viewer-shortcuts.d.ts +71 -0
- package/lib/visualizer/visualizer-context-menu.d.ts +55 -0
- package/lib/visualizer.component.d.ts +201 -447
- package/lib/workers/spatial-math-ops.d.ts +65 -0
- package/lib/workers/spatial-math-worker.d.ts +7 -0
- package/lib/workers/spatial-math.d.ts +74 -0
- package/package.json +12 -3
- package/src/lib/styles/_viz-icons-rules.scss +73 -0
- package/src/lib/styles/viz-icons.scss +14 -0
- package/esm2022/lib/implementations/napari-js/napari-axes-labels.mjs +0 -97
- package/esm2022/lib/implementations/napari-js/napari-navigator.mjs +0 -195
- package/esm2022/lib/implementations/napari-js/napari-scale-bar.mjs +0 -92
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs +0 -329
- package/fesm2022/jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs.map +0 -1
- package/lib/implementations/napari-js/napari-axes-labels.d.ts +0 -49
- package/lib/implementations/napari-js/napari-navigator.d.ts +0 -72
- package/lib/implementations/napari-js/napari-scale-bar.d.ts +0 -35
- package/src/lib/assets/cell-detection.svg +0 -37
- package/src/lib/assets/click.svg +0 -1
- package/src/lib/assets/colormap-luts.json +0 -1
- package/src/lib/assets/edit-selection-white.svg +0 -47
- package/src/lib/assets/icons/colormap-earth.png +0 -0
- package/src/lib/assets/icons/colormap-placeholder.png +0 -0
- package/src/lib/assets/icons/colormap-pubu.png +0 -0
- package/src/lib/assets/interactive-segmentation-cursor.svg +0 -1
- package/src/lib/assets/picture-segmentation.svg +0 -43
- package/src/lib/assets/test/download-379.svg +0 -1
- package/src/lib/assets/test/download-98.svg +0 -1
- package/src/lib/assets/test/json-1.svg +0 -1
- package/src/lib/assets/test/load-53.svg +0 -1
- package/src/lib/assets/test/mask-44.svg +0 -1
- package/src/lib/assets/test/mask-download-44.svg +0 -15
- package/src/lib/assets/test/mask-save-44.svg +0 -11
- package/src/lib/assets/test/overlay-1.svg +0 -1
- package/src/lib/assets/test/overlay-4.svg +0 -1
- package/src/lib/assets/test/region-26.svg +0 -1
- package/src/lib/assets/test/save-56.svg +0 -1
- package/src/lib/assets/test/upload-43.svg +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Physical scale bar for the napari-js WebGPU image view (jit-ui#102), mirroring the OSD
|
|
3
|
-
* backend's {@link OsdScaleBar}. napari keeps layers at pixel scale, so the camera's `zoom`
|
|
4
|
-
* (CSS px per world unit) is exactly screen px per image pixel; combined with the image's
|
|
5
|
-
* µm/pixel (`mppX`, from Bio-Formats `/tiles/info`) that gives a real-world bar length.
|
|
6
|
-
* Recomputes on every camera change and host resize. Hidden when the image has no physical size.
|
|
7
|
-
*/
|
|
8
|
-
/** Round up to a "nice" 1/2/5 × 10ⁿ value for scale-bar lengths. */
|
|
9
|
-
function niceLength(x) {
|
|
10
|
-
if (x <= 0)
|
|
11
|
-
return 1;
|
|
12
|
-
const base = Math.pow(10, Math.floor(Math.log10(x)));
|
|
13
|
-
const f = x / base;
|
|
14
|
-
const nice = f < 1.5 ? 1 : f < 3.5 ? 2 : f < 7.5 ? 5 : 10;
|
|
15
|
-
return nice * base;
|
|
16
|
-
}
|
|
17
|
-
/** Format a length given in micrometres, picking the unit that suits its magnitude (jit-service
|
|
18
|
-
* normalises whatever unit Bio-Formats reports to µm). */
|
|
19
|
-
export function formatUm(um) {
|
|
20
|
-
const trim = (n) => (n % 1 === 0 ? `${n}` : n.toFixed(1));
|
|
21
|
-
if (um >= 1e6)
|
|
22
|
-
return `${trim(um / 1e6)} m`;
|
|
23
|
-
if (um >= 1e4)
|
|
24
|
-
return `${trim(um / 1e4)} cm`;
|
|
25
|
-
if (um >= 1e3)
|
|
26
|
-
return `${trim(um / 1e3)} mm`;
|
|
27
|
-
if (um >= 1)
|
|
28
|
-
return `${trim(um)} µm`;
|
|
29
|
-
return `${trim(um * 1000)} nm`;
|
|
30
|
-
}
|
|
31
|
-
export class NapariScaleBar {
|
|
32
|
-
constructor(host, camera, mppX) {
|
|
33
|
-
this.host = host;
|
|
34
|
-
this.camera = camera;
|
|
35
|
-
this.mppX = mppX;
|
|
36
|
-
// The bar is absolutely positioned within the host, so the host must establish a containing
|
|
37
|
-
// block (the plot host is often statically positioned).
|
|
38
|
-
if (getComputedStyle(host).position === 'static')
|
|
39
|
-
host.style.position = 'relative';
|
|
40
|
-
this.bar = document.createElement('div');
|
|
41
|
-
Object.assign(this.bar.style, {
|
|
42
|
-
position: 'absolute',
|
|
43
|
-
left: '12px',
|
|
44
|
-
bottom: '12px',
|
|
45
|
-
zIndex: '30',
|
|
46
|
-
pointerEvents: 'none',
|
|
47
|
-
color: '#fff',
|
|
48
|
-
font: '11px sans-serif',
|
|
49
|
-
textShadow: '0 0 3px #000',
|
|
50
|
-
textAlign: 'center',
|
|
51
|
-
userSelect: 'none',
|
|
52
|
-
});
|
|
53
|
-
this.label = document.createElement('span');
|
|
54
|
-
this.line = document.createElement('div');
|
|
55
|
-
Object.assign(this.line.style, {
|
|
56
|
-
height: '4px',
|
|
57
|
-
marginTop: '2px',
|
|
58
|
-
background: 'rgba(255,255,255,0.9)',
|
|
59
|
-
borderLeft: '1px solid #fff',
|
|
60
|
-
borderRight: '1px solid #fff',
|
|
61
|
-
boxShadow: '0 0 3px #000',
|
|
62
|
-
});
|
|
63
|
-
this.bar.appendChild(this.label);
|
|
64
|
-
this.bar.appendChild(this.line);
|
|
65
|
-
this.host.appendChild(this.bar);
|
|
66
|
-
this.disconnectCamera = this.camera.changed.connect(() => this.update());
|
|
67
|
-
if (typeof ResizeObserver !== 'undefined') {
|
|
68
|
-
this.resizeObserver = new ResizeObserver(() => this.update());
|
|
69
|
-
this.resizeObserver.observe(this.host);
|
|
70
|
-
}
|
|
71
|
-
this.update();
|
|
72
|
-
}
|
|
73
|
-
update() {
|
|
74
|
-
const pxPerImagePx = this.camera.zoom; // CSS screen px per image pixel
|
|
75
|
-
if (!(this.mppX > 0) || !(pxPerImagePx > 0)) {
|
|
76
|
-
this.bar.style.display = 'none';
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const umPerScreenPx = this.mppX / pxPerImagePx;
|
|
80
|
-
const niceUm = niceLength(120 * umPerScreenPx); // target ~120px bar
|
|
81
|
-
this.bar.style.display = '';
|
|
82
|
-
this.line.style.width = `${Math.round(niceUm / umPerScreenPx)}px`;
|
|
83
|
-
this.label.textContent = formatUm(niceUm);
|
|
84
|
-
}
|
|
85
|
-
destroy() {
|
|
86
|
-
this.disconnectCamera();
|
|
87
|
-
this.resizeObserver?.disconnect();
|
|
88
|
-
if (this.bar.parentNode)
|
|
89
|
-
this.bar.parentNode.removeChild(this.bar);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmFwYXJpLXNjYWxlLWJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9saWIvaW1wbGVtZW50YXRpb25zL25hcGFyaS1qcy9uYXBhcmktc2NhbGUtYmFyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILG9FQUFvRTtBQUNwRSxTQUFTLFVBQVUsQ0FBQyxDQUFTO0lBQzNCLElBQUksQ0FBQyxJQUFJLENBQUM7UUFBRSxPQUFPLENBQUMsQ0FBQztJQUNyQixNQUFNLElBQUksR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsRUFBRSxJQU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oaXMubGluZS5zdHlsZS53aWR0aCA9IGAke01hdGgucm91bmQobmljZVVtIC8gdW1QZXJTY3JlZW5QeCl9cHhgO1xuICAgIHRoaXMubGFiZWwudGV4dENvbnRlbnQgPSBmb3JtYXRVbShuaWNlVW0pO1xuICB9XG5cbiAgZGVzdHJveSgpOiB2b2lkIHtcbiAgICB0aGlzLmRpc2Nvbm5lY3RDYW1lcmEoKTtcbiAgICB0aGlzLnJlc2l6ZU9ic2VydmVyPy5kaXNjb25uZWN0KCk7XG4gICAgaWYgKHRoaXMuYmFyLnBhcmVudE5vZGUpIHRoaXMuYmFyLnBhcmVudE5vZGUucmVtb3ZlQ2hpbGQodGhpcy5iYXIpO1xuICB9XG59XG4iXX0=
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import * as ort from 'onnxruntime-web';
|
|
2
|
-
import { getOrtWasmBase } from './jax-data-science-sci-image-visualizer.mjs';
|
|
3
|
-
import '@angular/core';
|
|
4
|
-
import '@angular/common/http';
|
|
5
|
-
import 'rxjs';
|
|
6
|
-
import 'rxjs/operators';
|
|
7
|
-
import '@angular/common';
|
|
8
|
-
import '@angular/forms';
|
|
9
|
-
import 'primeng/toolbar';
|
|
10
|
-
import 'primeng/button';
|
|
11
|
-
import 'primeng/menu';
|
|
12
|
-
import 'primeng/dropdown';
|
|
13
|
-
import 'primeng/slider';
|
|
14
|
-
import 'primeng/treeselect';
|
|
15
|
-
import 'primeng/inputnumber';
|
|
16
|
-
import 'primeng/dialog';
|
|
17
|
-
import 'primeng/contextmenu';
|
|
18
|
-
import 'primeng/progressbar';
|
|
19
|
-
import 'primeng/toast';
|
|
20
|
-
import 'primeng/tooltip';
|
|
21
|
-
import 'primeng/ripple';
|
|
22
|
-
import 'primeng/table';
|
|
23
|
-
import 'primeng/paginator';
|
|
24
|
-
import 'primeng/overlaypanel';
|
|
25
|
-
import 'primeng/confirmdialog';
|
|
26
|
-
import 'primeng/inputtext';
|
|
27
|
-
import 'primeng/checkbox';
|
|
28
|
-
import 'primeng/multiselect';
|
|
29
|
-
import 'primeng/radiobutton';
|
|
30
|
-
import 'primeng/selectbutton';
|
|
31
|
-
import 'primeng/autocomplete';
|
|
32
|
-
import 'primeng/api';
|
|
33
|
-
import 'file-saver';
|
|
34
|
-
import 'plotly.js-dist-min';
|
|
35
|
-
import 'image-js';
|
|
36
|
-
import 'buffer';
|
|
37
|
-
import 'openseadragon';
|
|
38
|
-
import 'napari-js';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Shared, DOM-free SAM inference primitives used by BOTH inference backends:
|
|
42
|
-
* the in-process session (`OnnxSamSession`, main thread) and the dedicated
|
|
43
|
-
* Web Worker (`onnx-sam.worker`). Keeping these here avoids duplicating the
|
|
44
|
-
* preprocessing / decoder-prompt math and keeps the worker DOM-free (it can't
|
|
45
|
-
* import sam-prompt.ts, which pulls in DOM types).
|
|
46
|
-
*/
|
|
47
|
-
const PIXEL_MEAN = [123.675, 116.28, 103.53];
|
|
48
|
-
const PIXEL_STD = [58.395, 57.12, 57.375];
|
|
49
|
-
const MODEL_CACHE = 'sam-onnx';
|
|
50
|
-
/** Fetch a model as an ArrayBuffer, streaming progress and caching in the Cache
|
|
51
|
-
* API (so it isn't re-downloaded). Cache hit → progress jumps to 1. Works on
|
|
52
|
-
* the main thread and in a worker (both have `fetch` + `caches`). */
|
|
53
|
-
async function fetchModel(url, onProgress) {
|
|
54
|
-
const cache = typeof caches !== 'undefined' ? await caches.open(MODEL_CACHE).catch(() => null) : null;
|
|
55
|
-
const hit = cache ? await cache.match(url) : null;
|
|
56
|
-
if (hit) {
|
|
57
|
-
onProgress?.(1);
|
|
58
|
-
return await hit.arrayBuffer();
|
|
59
|
-
}
|
|
60
|
-
const resp = await fetch(url);
|
|
61
|
-
if (!resp.ok)
|
|
62
|
-
throw new Error(`fetch ${url} failed: HTTP ${resp.status}`);
|
|
63
|
-
const total = Number(resp.headers.get('content-length')) || 0;
|
|
64
|
-
if (!resp.body || !total) {
|
|
65
|
-
const buf = await resp.arrayBuffer();
|
|
66
|
-
onProgress?.(1);
|
|
67
|
-
if (cache)
|
|
68
|
-
await cache.put(url, new Response(buf)).catch(() => undefined);
|
|
69
|
-
return buf;
|
|
70
|
-
}
|
|
71
|
-
const reader = resp.body.getReader();
|
|
72
|
-
const chunks = [];
|
|
73
|
-
let received = 0;
|
|
74
|
-
for (;;) {
|
|
75
|
-
const { done, value } = await reader.read();
|
|
76
|
-
if (done)
|
|
77
|
-
break;
|
|
78
|
-
chunks.push(value);
|
|
79
|
-
received += value.length;
|
|
80
|
-
onProgress?.(received / total);
|
|
81
|
-
}
|
|
82
|
-
const out = new Uint8Array(received);
|
|
83
|
-
let off = 0;
|
|
84
|
-
for (const c of chunks) {
|
|
85
|
-
out.set(c, off);
|
|
86
|
-
off += c.length;
|
|
87
|
-
}
|
|
88
|
-
if (cache) {
|
|
89
|
-
await cache.put(url, new Response(out.slice(), { headers: { 'content-length': String(received) } }))
|
|
90
|
-
.catch(() => undefined);
|
|
91
|
-
}
|
|
92
|
-
onProgress?.(1);
|
|
93
|
-
return out.buffer;
|
|
94
|
-
}
|
|
95
|
-
/** Resize (long side → size, bilinear), pad to size×size, SAM-normalize → CHW float32. */
|
|
96
|
-
function preprocess(data, width, height, size, scale) {
|
|
97
|
-
const newW = Math.round(width * scale);
|
|
98
|
-
const newH = Math.round(height * scale);
|
|
99
|
-
const chw = new Float32Array(3 * size * size); // zero-padded
|
|
100
|
-
for (let y = 0; y < newH; y++) {
|
|
101
|
-
const sy = Math.min(height - 1, y / scale);
|
|
102
|
-
const y0 = Math.floor(sy);
|
|
103
|
-
const fy = sy - y0;
|
|
104
|
-
const y1 = Math.min(height - 1, y0 + 1);
|
|
105
|
-
for (let x = 0; x < newW; x++) {
|
|
106
|
-
const sx = Math.min(width - 1, x / scale);
|
|
107
|
-
const x0 = Math.floor(sx);
|
|
108
|
-
const fx = sx - x0;
|
|
109
|
-
const x1 = Math.min(width - 1, x0 + 1);
|
|
110
|
-
for (let c = 0; c < 3; c++) {
|
|
111
|
-
const p00 = data[(y0 * width + x0) * 4 + c];
|
|
112
|
-
const p01 = data[(y0 * width + x1) * 4 + c];
|
|
113
|
-
const p10 = data[(y1 * width + x0) * 4 + c];
|
|
114
|
-
const p11 = data[(y1 * width + x1) * 4 + c];
|
|
115
|
-
const top = p00 + (p01 - p00) * fx;
|
|
116
|
-
const bot = p10 + (p11 - p10) * fx;
|
|
117
|
-
const v = top + (bot - top) * fy;
|
|
118
|
-
chw[c * size * size + y * size + x] = (v - PIXEL_MEAN[c]) / PIXEL_STD[c];
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return chw;
|
|
123
|
-
}
|
|
124
|
-
/** Assemble decoder `point_coords`/`point_labels` from a prompt, in encoder
|
|
125
|
-
* (resized) space. Box = two points labelled 2/3; points use 1/0; a points-only
|
|
126
|
-
* prompt pads the absent box slot with `[0,0]` labelled -1. */
|
|
127
|
-
function buildDecoderPrompt(prompt, scale) {
|
|
128
|
-
const coords = [];
|
|
129
|
-
const labels = [];
|
|
130
|
-
for (const p of prompt.points ?? []) {
|
|
131
|
-
coords.push(p.x * scale, p.y * scale);
|
|
132
|
-
labels.push(p.label);
|
|
133
|
-
}
|
|
134
|
-
if (prompt.box) {
|
|
135
|
-
const b = prompt.box;
|
|
136
|
-
coords.push(b.x0 * scale, b.y0 * scale);
|
|
137
|
-
labels.push(2);
|
|
138
|
-
coords.push(b.x1 * scale, b.y1 * scale);
|
|
139
|
-
labels.push(3);
|
|
140
|
-
}
|
|
141
|
-
else if (labels.length > 0) {
|
|
142
|
-
coords.push(0, 0);
|
|
143
|
-
labels.push(-1);
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
pointCoords: Float32Array.from(coords),
|
|
147
|
-
pointLabels: Float32Array.from(labels),
|
|
148
|
-
numPoints: labels.length,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/** Binarize mask logits (`> threshold`) into a 0/1 mask. */
|
|
152
|
-
function binarizeMask(logits, threshold = 0) {
|
|
153
|
-
const out = new Uint8Array(logits.length);
|
|
154
|
-
for (let i = 0; i < logits.length; i++)
|
|
155
|
-
out[i] = logits[i] > threshold ? 1 : 0;
|
|
156
|
-
return out;
|
|
157
|
-
}
|
|
158
|
-
/** Index of the highest-scoring mask in a multimask decoder output. */
|
|
159
|
-
function bestMaskIndex(iou) {
|
|
160
|
-
let best = 0;
|
|
161
|
-
for (let i = 1; i < iou.length; i++)
|
|
162
|
-
if (iou[i] > iou[best])
|
|
163
|
-
best = i;
|
|
164
|
-
return best;
|
|
165
|
-
}
|
|
166
|
-
/** Run the encoder on an RGBA image → a reusable embedding. */
|
|
167
|
-
async function runEncoder(encoder, data, width, height, inputSize) {
|
|
168
|
-
const scale = inputSize / Math.max(width, height);
|
|
169
|
-
const input = preprocess(data, width, height, inputSize, scale);
|
|
170
|
-
const out = await encoder.run({
|
|
171
|
-
[encoder.inputNames[0]]: new ort.Tensor('float32', input, [1, 3, inputSize, inputSize]),
|
|
172
|
-
});
|
|
173
|
-
const emb = out[encoder.outputNames[0]];
|
|
174
|
-
return {
|
|
175
|
-
data: emb.data, dims: emb.dims,
|
|
176
|
-
scale, imageWidth: width, imageHeight: height,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
/** Run the decoder for one prompt against a cached embedding → a binary mask. */
|
|
180
|
-
async function runDecoder(decoder, e, prompt) {
|
|
181
|
-
const { pointCoords, pointLabels, numPoints } = buildDecoderPrompt(prompt, e.scale);
|
|
182
|
-
const out = await decoder.run({
|
|
183
|
-
image_embeddings: new ort.Tensor('float32', e.data, e.dims),
|
|
184
|
-
point_coords: new ort.Tensor('float32', pointCoords, [1, numPoints, 2]),
|
|
185
|
-
point_labels: new ort.Tensor('float32', pointLabels, [1, numPoints]),
|
|
186
|
-
mask_input: new ort.Tensor('float32', new Float32Array(256 * 256), [1, 1, 256, 256]),
|
|
187
|
-
has_mask_input: new ort.Tensor('float32', Float32Array.from([0]), [1]),
|
|
188
|
-
orig_im_size: new ort.Tensor('float32', Float32Array.from([e.imageHeight, e.imageWidth]), [2]),
|
|
189
|
-
});
|
|
190
|
-
const masks = out['masks'] ?? out[decoder.outputNames[0]];
|
|
191
|
-
const iou = out['iou_predictions']?.data ?? Float32Array.from([1]);
|
|
192
|
-
const [, m, h, w] = masks.dims;
|
|
193
|
-
const idx = bestMaskIndex(iou.slice(0, m));
|
|
194
|
-
const logits = masks.data.subarray(idx * h * w, (idx + 1) * h * w);
|
|
195
|
-
return { mask: binarizeMask(logits), width: w, height: h, iou: iou[idx] ?? 1 };
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
class OnnxSamSession {
|
|
199
|
-
constructor() {
|
|
200
|
-
this.mode = null;
|
|
201
|
-
this.loaded = false;
|
|
202
|
-
this.model = null;
|
|
203
|
-
this.inputSize = 1024;
|
|
204
|
-
// ── worker mode ──
|
|
205
|
-
this.worker = null;
|
|
206
|
-
this.seq = 0;
|
|
207
|
-
this.pending = new Map();
|
|
208
|
-
// ── in-process mode ──
|
|
209
|
-
this.encoder = null;
|
|
210
|
-
this.decoder = null;
|
|
211
|
-
this.nextToken = 1;
|
|
212
|
-
this.embeddings = new Map();
|
|
213
|
-
}
|
|
214
|
-
async loadModel(model, onProgress) {
|
|
215
|
-
if (!model.encoderUrl || !model.decoderUrl) {
|
|
216
|
-
throw new Error(`SAM model "${model.id}" has no ONNX URLs configured.`);
|
|
217
|
-
}
|
|
218
|
-
this.model = model;
|
|
219
|
-
this.inputSize = model.inputSize;
|
|
220
|
-
const hasGpu = typeof navigator !== 'undefined' && 'gpu' in navigator;
|
|
221
|
-
const eps = model.encoderProviders ?? (hasGpu ? ['webgpu', 'wasm'] : ['wasm']);
|
|
222
|
-
const usesWebGpu = eps.includes('webgpu');
|
|
223
|
-
// WebGPU must run in the worker (else it freezes the main thread); small
|
|
224
|
-
// WASM models opt into the faster in-process path via `inProcess`.
|
|
225
|
-
this.mode = !usesWebGpu && model.inProcess ? 'inproc' : 'worker';
|
|
226
|
-
if (this.mode === 'inproc') {
|
|
227
|
-
ort.env.wasm.wasmPaths = getOrtWasmBase();
|
|
228
|
-
const encBuf = await fetchModel(model.encoderUrl, onProgress);
|
|
229
|
-
const decBuf = await fetchModel(model.decoderUrl);
|
|
230
|
-
this.encoder = await ort.InferenceSession.create(encBuf, { executionProviders: eps });
|
|
231
|
-
this.decoder = await ort.InferenceSession.create(decBuf, { executionProviders: ['wasm'] });
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
await this.call({
|
|
235
|
-
type: 'load',
|
|
236
|
-
encoderUrl: model.encoderUrl,
|
|
237
|
-
decoderUrl: model.decoderUrl,
|
|
238
|
-
wasmPaths: getOrtWasmBase(),
|
|
239
|
-
inputSize: model.inputSize,
|
|
240
|
-
encoderProviders: model.encoderProviders,
|
|
241
|
-
}, [], onProgress);
|
|
242
|
-
}
|
|
243
|
-
this.loaded = true;
|
|
244
|
-
}
|
|
245
|
-
isLoaded() {
|
|
246
|
-
return this.loaded;
|
|
247
|
-
}
|
|
248
|
-
async embed(image) {
|
|
249
|
-
if (this.mode === 'inproc') {
|
|
250
|
-
const e = await runEncoder(this.encoder, image.data, image.width, image.height, this.inputSize);
|
|
251
|
-
const token = this.nextToken++;
|
|
252
|
-
this.embeddings.set(token, e);
|
|
253
|
-
if (this.embeddings.size > 3)
|
|
254
|
-
this.embeddings.delete(this.embeddings.keys().next().value);
|
|
255
|
-
return {
|
|
256
|
-
data: new Float32Array(0), dims: e.dims, scale: e.scale,
|
|
257
|
-
imageWidth: e.imageWidth, imageHeight: e.imageHeight, token,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
// worker: transfer the RGBA buffer (callers pass a fresh frame buffer).
|
|
261
|
-
const buffer = image.data.buffer;
|
|
262
|
-
const res = await this.call({ type: 'embed', width: image.width, height: image.height, buffer }, [buffer]);
|
|
263
|
-
return {
|
|
264
|
-
data: new Float32Array(0), dims: res.dims, scale: res.scale,
|
|
265
|
-
imageWidth: res.imageWidth, imageHeight: res.imageHeight, token: res.token,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
async decode(embedding, prompt) {
|
|
269
|
-
if (this.mode === 'inproc') {
|
|
270
|
-
const e = this.embeddings.get(embedding.token);
|
|
271
|
-
if (!e)
|
|
272
|
-
throw new Error('SAM embedding expired; re-encode the image.');
|
|
273
|
-
return runDecoder(this.decoder, e, prompt);
|
|
274
|
-
}
|
|
275
|
-
const res = await this.call({ type: 'decode', token: embedding.token, prompt });
|
|
276
|
-
return { mask: new Uint8Array(res.buffer), width: res.width, height: res.height, iou: res.iou };
|
|
277
|
-
}
|
|
278
|
-
dispose() {
|
|
279
|
-
this.worker?.terminate();
|
|
280
|
-
this.worker = null;
|
|
281
|
-
this.pending.clear();
|
|
282
|
-
this.encoder?.release?.();
|
|
283
|
-
this.decoder?.release?.();
|
|
284
|
-
this.encoder = this.decoder = null;
|
|
285
|
-
this.embeddings.clear();
|
|
286
|
-
this.loaded = false;
|
|
287
|
-
this.mode = null;
|
|
288
|
-
}
|
|
289
|
-
// ── worker plumbing ──────────────────────────────────────────────────────
|
|
290
|
-
ensureWorker() {
|
|
291
|
-
if (this.worker)
|
|
292
|
-
return this.worker;
|
|
293
|
-
const worker = new Worker(new URL('./onnx-sam.worker', import.meta.url), { type: 'module' });
|
|
294
|
-
worker.onmessage = (ev) => {
|
|
295
|
-
const m = ev.data;
|
|
296
|
-
const p = this.pending.get(m.id);
|
|
297
|
-
if (!p)
|
|
298
|
-
return;
|
|
299
|
-
if (m.type === 'progress') {
|
|
300
|
-
p.onProgress?.(m.fraction);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
this.pending.delete(m.id);
|
|
304
|
-
if (m.type === 'error')
|
|
305
|
-
p.reject(new Error(m.error));
|
|
306
|
-
else
|
|
307
|
-
p.resolve(m);
|
|
308
|
-
};
|
|
309
|
-
worker.onerror = (ev) => {
|
|
310
|
-
const err = new Error(ev.message || 'SAM worker crashed.');
|
|
311
|
-
for (const p of this.pending.values())
|
|
312
|
-
p.reject(err);
|
|
313
|
-
this.pending.clear();
|
|
314
|
-
};
|
|
315
|
-
this.worker = worker;
|
|
316
|
-
return worker;
|
|
317
|
-
}
|
|
318
|
-
call(msg, transfer = [], onProgress) {
|
|
319
|
-
const id = ++this.seq;
|
|
320
|
-
const worker = this.ensureWorker();
|
|
321
|
-
return new Promise((resolve, reject) => {
|
|
322
|
-
this.pending.set(id, { resolve, reject, onProgress });
|
|
323
|
-
worker.postMessage({ ...msg, id }, transfer);
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
export { OnnxSamSession };
|
|
329
|
-
//# sourceMappingURL=jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jax-data-science-sci-image-visualizer-onnx-sam-session-BwP-A11m.mjs","sources":["../../src/lib/toolbar/segmentation/sam-onnx-core.ts","../../src/lib/toolbar/segmentation/onnx-sam-session.ts"],"sourcesContent":["import * as ort from 'onnxruntime-web';\n\nimport type { SamPrompt } from '../../contracts/sam.contract';\n\n/**\n * Shared, DOM-free SAM inference primitives used by BOTH inference backends:\n * the in-process session (`OnnxSamSession`, main thread) and the dedicated\n * Web Worker (`onnx-sam.worker`). Keeping these here avoids duplicating the\n * preprocessing / decoder-prompt math and keeps the worker DOM-free (it can't\n * import sam-prompt.ts, which pulls in DOM types).\n */\n\nexport const PIXEL_MEAN = [123.675, 116.28, 103.53];\nexport const PIXEL_STD = [58.395, 57.12, 57.375];\nconst MODEL_CACHE = 'sam-onnx';\n\n/** Encoder output for one image, reused across prompts. */\nexport interface CoreEmbedding {\n data: Float32Array;\n dims: number[];\n scale: number;\n imageWidth: number;\n imageHeight: number;\n}\n\n/** Decoder output: a binary mask at original-image resolution. */\nexport interface CoreMask {\n mask: Uint8Array;\n width: number;\n height: number;\n iou: number;\n}\n\n/** Fetch a model as an ArrayBuffer, streaming progress and caching in the Cache\n * API (so it isn't re-downloaded). Cache hit → progress jumps to 1. Works on\n * the main thread and in a worker (both have `fetch` + `caches`). */\nexport async function fetchModel(url: string, onProgress?: (f: number) => void): Promise<ArrayBuffer> {\n const cache = typeof caches !== 'undefined' ? await caches.open(MODEL_CACHE).catch(() => null) : null;\n const hit = cache ? await cache.match(url) : null;\n if (hit) { onProgress?.(1); return await hit.arrayBuffer(); }\n\n const resp = await fetch(url);\n if (!resp.ok) throw new Error(`fetch ${url} failed: HTTP ${resp.status}`);\n const total = Number(resp.headers.get('content-length')) || 0;\n if (!resp.body || !total) {\n const buf = await resp.arrayBuffer();\n onProgress?.(1);\n if (cache) await cache.put(url, new Response(buf)).catch(() => undefined);\n return buf;\n }\n const reader = resp.body.getReader();\n const chunks: Uint8Array[] = [];\n let received = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n chunks.push(value);\n received += value.length;\n onProgress?.(received / total);\n }\n const out = new Uint8Array(received);\n let off = 0;\n for (const c of chunks) { out.set(c, off); off += c.length; }\n if (cache) {\n await cache.put(url, new Response(out.slice(), { headers: { 'content-length': String(received) } }))\n .catch(() => undefined);\n }\n onProgress?.(1);\n return out.buffer;\n}\n\n/** Resize (long side → size, bilinear), pad to size×size, SAM-normalize → CHW float32. */\nexport function preprocess(\n data: Uint8ClampedArray, width: number, height: number, size: number, scale: number,\n): Float32Array {\n const newW = Math.round(width * scale);\n const newH = Math.round(height * scale);\n const chw = new Float32Array(3 * size * size); // zero-padded\n for (let y = 0; y < newH; y++) {\n const sy = Math.min(height - 1, y / scale);\n const y0 = Math.floor(sy);\n const fy = sy - y0;\n const y1 = Math.min(height - 1, y0 + 1);\n for (let x = 0; x < newW; x++) {\n const sx = Math.min(width - 1, x / scale);\n const x0 = Math.floor(sx);\n const fx = sx - x0;\n const x1 = Math.min(width - 1, x0 + 1);\n for (let c = 0; c < 3; c++) {\n const p00 = data[(y0 * width + x0) * 4 + c];\n const p01 = data[(y0 * width + x1) * 4 + c];\n const p10 = data[(y1 * width + x0) * 4 + c];\n const p11 = data[(y1 * width + x1) * 4 + c];\n const top = p00 + (p01 - p00) * fx;\n const bot = p10 + (p11 - p10) * fx;\n const v = top + (bot - top) * fy;\n chw[c * size * size + y * size + x] = (v - PIXEL_MEAN[c]) / PIXEL_STD[c];\n }\n }\n }\n return chw;\n}\n\n/** Assemble decoder `point_coords`/`point_labels` from a prompt, in encoder\n * (resized) space. Box = two points labelled 2/3; points use 1/0; a points-only\n * prompt pads the absent box slot with `[0,0]` labelled -1. */\nexport function buildDecoderPrompt(\n prompt: SamPrompt, scale: number,\n): { pointCoords: Float32Array; pointLabels: Float32Array; numPoints: number } {\n const coords: number[] = [];\n const labels: number[] = [];\n for (const p of prompt.points ?? []) { coords.push(p.x * scale, p.y * scale); labels.push(p.label); }\n if (prompt.box) {\n const b = prompt.box;\n coords.push(b.x0 * scale, b.y0 * scale); labels.push(2);\n coords.push(b.x1 * scale, b.y1 * scale); labels.push(3);\n } else if (labels.length > 0) {\n coords.push(0, 0); labels.push(-1);\n }\n return {\n pointCoords: Float32Array.from(coords),\n pointLabels: Float32Array.from(labels),\n numPoints: labels.length,\n };\n}\n\n/** Binarize mask logits (`> threshold`) into a 0/1 mask. */\nexport function binarizeMask(logits: Float32Array, threshold = 0): Uint8Array {\n const out = new Uint8Array(logits.length);\n for (let i = 0; i < logits.length; i++) out[i] = logits[i] > threshold ? 1 : 0;\n return out;\n}\n\n/** Index of the highest-scoring mask in a multimask decoder output. */\nexport function bestMaskIndex(iou: Float32Array | number[]): number {\n let best = 0;\n for (let i = 1; i < iou.length; i++) if (iou[i] > iou[best]) best = i;\n return best;\n}\n\n/** Run the encoder on an RGBA image → a reusable embedding. */\nexport async function runEncoder(\n encoder: ort.InferenceSession, data: Uint8ClampedArray, width: number, height: number, inputSize: number,\n): Promise<CoreEmbedding> {\n const scale = inputSize / Math.max(width, height);\n const input = preprocess(data, width, height, inputSize, scale);\n const out = await encoder.run({\n [encoder.inputNames[0]]: new ort.Tensor('float32', input, [1, 3, inputSize, inputSize]),\n });\n const emb = out[encoder.outputNames[0]];\n return {\n data: emb.data as Float32Array, dims: emb.dims as number[],\n scale, imageWidth: width, imageHeight: height,\n };\n}\n\n/** Run the decoder for one prompt against a cached embedding → a binary mask. */\nexport async function runDecoder(\n decoder: ort.InferenceSession, e: CoreEmbedding, prompt: SamPrompt,\n): Promise<CoreMask> {\n const { pointCoords, pointLabels, numPoints } = buildDecoderPrompt(prompt, e.scale);\n const out = await decoder.run({\n image_embeddings: new ort.Tensor('float32', e.data, e.dims),\n point_coords: new ort.Tensor('float32', pointCoords, [1, numPoints, 2]),\n point_labels: new ort.Tensor('float32', pointLabels, [1, numPoints]),\n mask_input: new ort.Tensor('float32', new Float32Array(256 * 256), [1, 1, 256, 256]),\n has_mask_input: new ort.Tensor('float32', Float32Array.from([0]), [1]),\n orig_im_size: new ort.Tensor('float32', Float32Array.from([e.imageHeight, e.imageWidth]), [2]),\n });\n const masks = out['masks'] ?? out[decoder.outputNames[0]];\n const iou = (out['iou_predictions']?.data as Float32Array) ?? Float32Array.from([1]);\n const [, m, h, w] = masks.dims as number[];\n const idx = bestMaskIndex(iou.slice(0, m));\n const logits = (masks.data as Float32Array).subarray(idx * h * w, (idx + 1) * h * w);\n return { mask: binarizeMask(logits), width: w, height: h, iou: iou[idx] ?? 1 };\n}\n","import * as ort from 'onnxruntime-web';\n\nimport {\n ISamSession, SamEmbedding, SamMaskResult, SamModelDef, SamPrompt,\n} from '../../contracts/sam.contract';\nimport { fetchModel, runEncoder, runDecoder, type CoreEmbedding } from './sam-onnx-core';\nimport { getOrtWasmBase } from './ort-runtime-config';\n\n/**\n * onnxruntime-web implementation of {@link ISamSession} (jit-ui#90), with two\n * execution modes chosen per model:\n *\n * - **in-process** (main thread) — for small WASM models flagged `inProcess`\n * (e.g. micro-sam ViT-T). Fast load + inference with no Web Worker spawn /\n * second ORT runtime / message round-trips; the brief encode runs on the main\n * thread (fine for a tiny model).\n * - **worker** — for WebGPU models (e.g. ViT-B, patho-sam fp16) whose heavy\n * encode would otherwise freeze the tab. Runs in {@link ./onnx-sam.worker} so\n * the UI stays responsive (the spinner animates).\n *\n * Both modes share their inference math via {@link ./sam-onnx-core}. Lazy-imported\n * by the SAM tools so onnxruntime-web / the worker never load in unit tests or\n * the initial bundle.\n */\ntype Pending = {\n resolve: (msg: any) => void;\n reject: (err: Error) => void;\n onProgress?: (fraction: number) => void;\n};\n\nexport class OnnxSamSession implements ISamSession {\n private mode: 'inproc' | 'worker' | null = null;\n private loaded = false;\n private model: SamModelDef | null = null;\n private inputSize = 1024;\n\n // ── worker mode ──\n private worker: Worker | null = null;\n private seq = 0;\n private readonly pending = new Map<number, Pending>();\n\n // ── in-process mode ──\n private encoder: ort.InferenceSession | null = null;\n private decoder: ort.InferenceSession | null = null;\n private nextToken = 1;\n private readonly embeddings = new Map<number, CoreEmbedding>();\n\n async loadModel(model: SamModelDef, onProgress?: (fraction: number) => void): Promise<void> {\n if (!model.encoderUrl || !model.decoderUrl) {\n throw new Error(`SAM model \"${model.id}\" has no ONNX URLs configured.`);\n }\n this.model = model;\n this.inputSize = model.inputSize;\n const hasGpu = typeof navigator !== 'undefined' && 'gpu' in navigator;\n const eps: string[] = model.encoderProviders ?? (hasGpu ? ['webgpu', 'wasm'] : ['wasm']);\n const usesWebGpu = eps.includes('webgpu');\n // WebGPU must run in the worker (else it freezes the main thread); small\n // WASM models opt into the faster in-process path via `inProcess`.\n this.mode = !usesWebGpu && model.inProcess ? 'inproc' : 'worker';\n\n if (this.mode === 'inproc') {\n ort.env.wasm.wasmPaths = getOrtWasmBase();\n const encBuf = await fetchModel(model.encoderUrl, onProgress);\n const decBuf = await fetchModel(model.decoderUrl);\n this.encoder = await ort.InferenceSession.create(encBuf, { executionProviders: eps });\n this.decoder = await ort.InferenceSession.create(decBuf, { executionProviders: ['wasm'] });\n } else {\n await this.call({\n type: 'load',\n encoderUrl: model.encoderUrl,\n decoderUrl: model.decoderUrl,\n wasmPaths: getOrtWasmBase(),\n inputSize: model.inputSize,\n encoderProviders: model.encoderProviders,\n }, [], onProgress);\n }\n this.loaded = true;\n }\n\n isLoaded(): boolean {\n return this.loaded;\n }\n\n async embed(image: { data: Uint8ClampedArray; width: number; height: number }): Promise<SamEmbedding> {\n if (this.mode === 'inproc') {\n const e = await runEncoder(this.encoder!, image.data, image.width, image.height, this.inputSize);\n const token = this.nextToken++;\n this.embeddings.set(token, e);\n if (this.embeddings.size > 3) this.embeddings.delete(this.embeddings.keys().next().value as number);\n return {\n data: new Float32Array(0), dims: e.dims, scale: e.scale,\n imageWidth: e.imageWidth, imageHeight: e.imageHeight, token,\n };\n }\n // worker: transfer the RGBA buffer (callers pass a fresh frame buffer).\n const buffer = image.data.buffer;\n const res = await this.call({ type: 'embed', width: image.width, height: image.height, buffer }, [buffer]);\n return {\n data: new Float32Array(0), dims: res.dims, scale: res.scale,\n imageWidth: res.imageWidth, imageHeight: res.imageHeight, token: res.token,\n };\n }\n\n async decode(embedding: SamEmbedding, prompt: SamPrompt): Promise<SamMaskResult> {\n if (this.mode === 'inproc') {\n const e = this.embeddings.get(embedding.token as number);\n if (!e) throw new Error('SAM embedding expired; re-encode the image.');\n return runDecoder(this.decoder!, e, prompt);\n }\n const res = await this.call({ type: 'decode', token: embedding.token, prompt });\n return { mask: new Uint8Array(res.buffer), width: res.width, height: res.height, iou: res.iou };\n }\n\n dispose(): void {\n this.worker?.terminate();\n this.worker = null;\n this.pending.clear();\n this.encoder?.release?.();\n this.decoder?.release?.();\n this.encoder = this.decoder = null;\n this.embeddings.clear();\n this.loaded = false;\n this.mode = null;\n }\n\n // ── worker plumbing ──────────────────────────────────────────────────────\n private ensureWorker(): Worker {\n if (this.worker) return this.worker;\n const worker = new Worker(new URL('./onnx-sam.worker', import.meta.url), { type: 'module' });\n worker.onmessage = (ev: MessageEvent) => {\n const m = ev.data;\n const p = this.pending.get(m.id);\n if (!p) return;\n if (m.type === 'progress') { p.onProgress?.(m.fraction); return; }\n this.pending.delete(m.id);\n if (m.type === 'error') p.reject(new Error(m.error));\n else p.resolve(m);\n };\n worker.onerror = (ev: ErrorEvent) => {\n const err = new Error(ev.message || 'SAM worker crashed.');\n for (const p of this.pending.values()) p.reject(err);\n this.pending.clear();\n };\n this.worker = worker;\n return worker;\n }\n\n private call(msg: any, transfer: Transferable[] = [], onProgress?: (f: number) => void): Promise<any> {\n const id = ++this.seq;\n const worker = this.ensureWorker();\n return new Promise((resolve, reject) => {\n this.pending.set(id, { resolve, reject, onProgress });\n worker.postMessage({ ...msg, id }, transfer);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;AAMG;AAEI,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AAC5C,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;AAChD,MAAM,WAAW,GAAG,UAAU;AAmB9B;;AAEsE;AAC/D,eAAe,UAAU,CAAC,GAAW,EAAE,UAAgC,EAAA;AAC5E,IAAA,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;AACrG,IAAA,MAAM,GAAG,GAAG,KAAK,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI;IACjD,IAAI,GAAG,EAAE;AAAE,QAAA,UAAU,GAAG,CAAC,CAAC;AAAE,QAAA,OAAO,MAAM,GAAG,CAAC,WAAW,EAAE;IAAE;AAE5D,IAAA,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC;IAC7B,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,CAAA,MAAA,EAAS,GAAG,CAAA,cAAA,EAA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AI,qBAAqB,CAAC;YAC1D,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AAAE,gBAAA,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AACpD,YAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;AACtB,QAAA,CAAC;AACD,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,OAAO,MAAM;IACf;AAEQ,IAAA,IAAI,CAAC,GAAQ,EAAE,QAAA,GAA2B,EAAE,EAAE,UAAgC,EAAA;AACpF,QAAA,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG;AACrB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE;QAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,YAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACrD,YAAA,MAAM,CAAC,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC;AAC9C,QAAA,CAAC,CAAC;IACJ;AACD;;;;"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM text labels for the napari-js 3D axes gizmo (jit-ui#102). The {@link AxesLayer} draws the
|
|
3
|
-
* axis lines/ticks/box in WebGPU; this overlay adds the crisp X/Y/Z + scale text on top, projected
|
|
4
|
-
* with the 3D camera's view-projection so each label tracks its anchor as the volume orbits.
|
|
5
|
-
* Mirrors the {@link NapariScaleBar} overlay pattern (absolute-positioned over the host, updated on
|
|
6
|
-
* every `camera3d.changed`). Falls back to pixel/slice counts when no physical µm/pixel is known.
|
|
7
|
-
*/
|
|
8
|
-
/** One axis label: a world-space anchor (the axis end, in the volume's centred box), the text to
|
|
9
|
-
* show, and its colour (matching the WebGPU axis colour). */
|
|
10
|
-
export interface AxisLabelSpec {
|
|
11
|
-
anchor: [number, number, number];
|
|
12
|
-
text: string;
|
|
13
|
-
color: string;
|
|
14
|
-
}
|
|
15
|
-
/** The slice of napari's Camera3D this overlay reads. `viewProjection` is column-major (gl-matrix). */
|
|
16
|
-
export interface AxesLabelCamera3D {
|
|
17
|
-
viewProjection(vw: number, vh: number): ArrayLike<number>;
|
|
18
|
-
readonly changed: {
|
|
19
|
-
connect(listener: () => void): () => void;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Re-exported from napari-js, which owns the projection now.
|
|
24
|
-
*
|
|
25
|
-
* This used to be a local copy: the same column-major multiply, perspective divide and y-flip
|
|
26
|
-
* that {@link NapariVisualizerService.getSpatialScreenProjection} ALSO carried, written twice
|
|
27
|
-
* with two different behind-the-eye conventions. The renderer owns the camera and the clip
|
|
28
|
-
* convention, so it owns the projection; kept as a named export here only so the overlays that
|
|
29
|
-
* import it from this module do not all have to change.
|
|
30
|
-
*/
|
|
31
|
-
import { projectPoint } from 'napari-js';
|
|
32
|
-
export { projectPoint };
|
|
33
|
-
export declare class NapariAxesLabels {
|
|
34
|
-
private readonly host;
|
|
35
|
-
private readonly camera3d;
|
|
36
|
-
private readonly labels;
|
|
37
|
-
private readonly els;
|
|
38
|
-
private readonly disconnectCamera;
|
|
39
|
-
private readonly resizeObserver?;
|
|
40
|
-
private visible;
|
|
41
|
-
constructor(host: HTMLElement, camera3d: AxesLabelCamera3D, labels: AxisLabelSpec[]);
|
|
42
|
-
setVisible(visible: boolean): void;
|
|
43
|
-
/** Replace the label anchors/text in place (same count) and reproject — lets a host move the
|
|
44
|
-
* labels when the box geometry changes live (e.g. a Z-height gizmo restretching the volume)
|
|
45
|
-
* without tearing down and recreating the DOM elements (which would flicker). */
|
|
46
|
-
updateAnchors(labels: AxisLabelSpec[]): void;
|
|
47
|
-
private update;
|
|
48
|
-
destroy(): void;
|
|
49
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Overview navigator (minimap) for the napari-js 2D views, mirroring the OSD backend's
|
|
3
|
-
* built-in navigator: a thumbnail of the whole image in the bottom-right corner with the
|
|
4
|
-
* current viewport drawn on it. Clicking re-centres the main view on that point at the
|
|
5
|
-
* same zoom; dragging pans continuously — exactly OSD's behaviour.
|
|
6
|
-
*
|
|
7
|
-
* napari keeps layers at full-resolution pixel scale, so the camera's world units ARE
|
|
8
|
-
* image pixels and the thumbnail maps onto `[0, width) × [0, height)` directly.
|
|
9
|
-
*/
|
|
10
|
-
/** The slice of the napari 2D camera the navigator reads and drives. */
|
|
11
|
-
export interface NavigatorCamera {
|
|
12
|
-
center: readonly [number, number];
|
|
13
|
-
readonly zoom: number;
|
|
14
|
-
readonly changed: {
|
|
15
|
-
connect(listener: () => void): () => void;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/** Where the thumbnail sits inside the navigator box, in CSS px. */
|
|
19
|
-
export interface NavigatorLayout {
|
|
20
|
-
/** Box size. */
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
/** CSS px per world unit (image pixel). */
|
|
24
|
-
scale: number;
|
|
25
|
-
}
|
|
26
|
-
/** Fraction of the host's width the navigator takes — OSD's `navigatorSizeRatio`. */
|
|
27
|
-
export declare const NAVIGATOR_SIZE_RATIO = 0.16;
|
|
28
|
-
/** Box size and scale for a `worldW × worldH` image in a host `hostW` wide. */
|
|
29
|
-
export declare function navigatorLayout(hostW: number, worldW: number, worldH: number, ratio?: number): NavigatorLayout | null;
|
|
30
|
-
/** The part of the world the camera shows, as `[x0, y0, x1, y1]`. */
|
|
31
|
-
export declare function viewportWorldRect(center: readonly [number, number], zoom: number, hostW: number, hostH: number): [number, number, number, number];
|
|
32
|
-
/** A point in the navigator box → world coordinates, clamped to the image. */
|
|
33
|
-
export declare function navigatorToWorld(px: number, py: number, layout: NavigatorLayout, worldW: number, worldH: number): [number, number];
|
|
34
|
-
export declare class NapariNavigator {
|
|
35
|
-
private readonly host;
|
|
36
|
-
private readonly camera;
|
|
37
|
-
private worldW;
|
|
38
|
-
private worldH;
|
|
39
|
-
/** Called when the pointer enters the navigator — e.g. to hide a hover tooltip that
|
|
40
|
-
* was describing the canvas underneath. */
|
|
41
|
-
private readonly onEnter?;
|
|
42
|
-
private readonly box;
|
|
43
|
-
private readonly canvas;
|
|
44
|
-
private readonly region;
|
|
45
|
-
private readonly disconnectCamera;
|
|
46
|
-
private readonly resizeObserver?;
|
|
47
|
-
/** Aborted by destroy() to remove every DOM listener the box holds. */
|
|
48
|
-
private readonly listeners;
|
|
49
|
-
private layout;
|
|
50
|
-
private image;
|
|
51
|
-
private dragging;
|
|
52
|
-
private visible;
|
|
53
|
-
constructor(host: HTMLElement, camera: NavigatorCamera, worldW: number, worldH: number,
|
|
54
|
-
/** Called when the pointer enters the navigator — e.g. to hide a hover tooltip that
|
|
55
|
-
* was describing the canvas underneath. */
|
|
56
|
-
onEnter?: (() => void) | undefined);
|
|
57
|
-
/** The thumbnail to draw: any image of the whole world (a coarse pyramid level). */
|
|
58
|
-
setImage(image: CanvasImageSource | null): void;
|
|
59
|
-
/** The image's world size changed (another image was loaded). */
|
|
60
|
-
setWorld(width: number, height: number): void;
|
|
61
|
-
setVisible(visible: boolean): void;
|
|
62
|
-
destroy(): void;
|
|
63
|
-
private relayout;
|
|
64
|
-
private drawImage;
|
|
65
|
-
/** Draw the viewport rectangle, clipped to the box (as OSD does when zoomed out). */
|
|
66
|
-
private updateRegion;
|
|
67
|
-
/** Re-centre the main view on the navigator point under the pointer, keeping the zoom. */
|
|
68
|
-
private panTo;
|
|
69
|
-
private readonly onDown;
|
|
70
|
-
private readonly onMove;
|
|
71
|
-
private readonly onUp;
|
|
72
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Physical scale bar for the napari-js WebGPU image view (jit-ui#102), mirroring the OSD
|
|
3
|
-
* backend's {@link OsdScaleBar}. napari keeps layers at pixel scale, so the camera's `zoom`
|
|
4
|
-
* (CSS px per world unit) is exactly screen px per image pixel; combined with the image's
|
|
5
|
-
* µm/pixel (`mppX`, from Bio-Formats `/tiles/info`) that gives a real-world bar length.
|
|
6
|
-
* Recomputes on every camera change and host resize. Hidden when the image has no physical size.
|
|
7
|
-
*/
|
|
8
|
-
/** Format a length given in micrometres, picking the unit that suits its magnitude (jit-service
|
|
9
|
-
* normalises whatever unit Bio-Formats reports to µm). */
|
|
10
|
-
export declare function formatUm(um: number): string;
|
|
11
|
-
/**
|
|
12
|
-
* The slice of the napari Camera the scale bar reads (zoom = CSS px per world/image pixel).
|
|
13
|
-
*
|
|
14
|
-
* Exported so the 3D spatial view can satisfy it with a shim: an orbit camera has no `zoom`, but
|
|
15
|
-
* px-per-world-unit AT THE PIVOT DEPTH is well defined, and that is what a 3D scale bar means.
|
|
16
|
-
*/
|
|
17
|
-
export interface ScaleBarCamera {
|
|
18
|
-
readonly zoom: number;
|
|
19
|
-
readonly changed: {
|
|
20
|
-
connect(listener: () => void): () => void;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare class NapariScaleBar {
|
|
24
|
-
private readonly host;
|
|
25
|
-
private readonly camera;
|
|
26
|
-
private readonly mppX;
|
|
27
|
-
private readonly bar;
|
|
28
|
-
private readonly line;
|
|
29
|
-
private readonly label;
|
|
30
|
-
private readonly disconnectCamera;
|
|
31
|
-
private readonly resizeObserver?;
|
|
32
|
-
constructor(host: HTMLElement, camera: ScaleBarCamera, mppX: number);
|
|
33
|
-
private update;
|
|
34
|
-
destroy(): void;
|
|
35
|
-
}
|