copper3d 3.11.4 → 3.11.5
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 +45 -1
- package/ai-index/guides/nrrd-tools.md +100 -2
- package/ai-index/guides/segmentation-module.md +108 -2
- package/ai-index/manifest.json +5 -5
- package/ai-index/symbols.json +1 -1
- package/dist/Utils/segmentation/DragOperator.d.ts +6 -0
- package/dist/Utils/segmentation/DragOperator.js +9 -0
- package/dist/Utils/segmentation/DragOperator.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +38 -1
- package/dist/Utils/segmentation/NrrdTools.js +105 -2
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/RenderingUtils.d.ts +5 -9
- package/dist/Utils/segmentation/RenderingUtils.js +10 -116
- package/dist/Utils/segmentation/RenderingUtils.js.map +1 -1
- package/dist/Utils/segmentation/contourPaint.d.ts +37 -0
- package/dist/Utils/segmentation/contourPaint.js +128 -0
- package/dist/Utils/segmentation/contourPaint.js.map +1 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.js +5 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/MaskMirror.d.ts +42 -0
- package/dist/Utils/segmentation/tools/MaskMirror.js +165 -0
- package/dist/Utils/segmentation/tools/MaskMirror.js.map +1 -0
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +5 -0
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -1
- package/dist/Utils/segmentation/tools/ToolHost.d.ts +10 -2
- package/dist/bundle.esm.js +418 -112
- package/dist/bundle.umd.js +418 -112
- package/dist/types/Utils/segmentation/DragOperator.d.ts +6 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +38 -1
- package/dist/types/Utils/segmentation/RenderingUtils.d.ts +5 -9
- package/dist/types/Utils/segmentation/contourPaint.d.ts +37 -0
- package/dist/types/Utils/segmentation/tools/MaskMirror.d.ts +42 -0
- package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +10 -2
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { INewMaskData } from "./core/types";
|
|
2
2
|
import type { MaskVolume } from "./core/index";
|
|
3
3
|
import type { CanvasState } from "./CanvasState";
|
|
4
|
+
import type { MaskMirror } from "./tools/MaskMirror";
|
|
4
5
|
/**
|
|
5
6
|
* RenderingUtils — Rendering / slice-buffer helper methods.
|
|
6
7
|
*
|
|
@@ -15,6 +16,10 @@ export declare class RenderingUtils {
|
|
|
15
16
|
private state;
|
|
16
17
|
/** Injected callback — set by owner after construction. */
|
|
17
18
|
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
19
|
+
/** Set while this viewer draws another viewer's masks; painted after this viewer's own layers. */
|
|
20
|
+
mirror: MaskMirror | null;
|
|
21
|
+
/** Called after every composite. The owner refreshes the viewers mirroring this one. */
|
|
22
|
+
onComposited: (() => void) | null;
|
|
18
23
|
private _reusableSliceBuffer;
|
|
19
24
|
private _reusableBufferWidth;
|
|
20
25
|
private _reusableBufferHeight;
|
|
@@ -73,15 +78,6 @@ export declare class RenderingUtils {
|
|
|
73
78
|
* allocating a new ImageData per layer per slice switch.
|
|
74
79
|
*/
|
|
75
80
|
getOrCreateSliceBuffer(axis: "x" | "y" | "z"): ImageData | null;
|
|
76
|
-
/**
|
|
77
|
-
* Populate one cache entry's paths for one render mode.
|
|
78
|
-
*
|
|
79
|
-
* Split out because the two modes are built at different times: whichever is in use when
|
|
80
|
-
* a slice is first drawn, and the other one only if the clinician switches while still on
|
|
81
|
-
* that slice. Building both eagerly would make every slice scrub pay for a mode most
|
|
82
|
-
* sessions never turn on.
|
|
83
|
-
*/
|
|
84
|
-
private buildPaths;
|
|
85
81
|
/**
|
|
86
82
|
* Render a layer's slice onto the target canvas as vector contours.
|
|
87
83
|
*
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Outline stroke width, in screen pixels.
|
|
4
|
-
*
|
|
5
|
-
* Screen pixels rather than voxels so magnifying the image does not thicken the line over the
|
|
6
|
-
* boundary the clinician magnified it to see. Thin enough to sit on an edge, thick enough to
|
|
7
|
-
* stay visible against bright tissue.
|
|
8
|
-
*/
|
|
9
|
-
const OUTLINE_WIDTH_PX = 1.5;
|
|
1
|
+
import { contourEntry, paintContours } from "./contourPaint";
|
|
10
2
|
/**
|
|
11
3
|
* RenderingUtils — Rendering / slice-buffer helper methods.
|
|
12
4
|
*
|
|
@@ -21,6 +13,10 @@ export class RenderingUtils {
|
|
|
21
13
|
constructor(state) {
|
|
22
14
|
/** Injected callback — set by owner after construction. */
|
|
23
15
|
this.setEmptyCanvasSize = () => { };
|
|
16
|
+
/** Set while this viewer draws another viewer's masks; painted after this viewer's own layers. */
|
|
17
|
+
this.mirror = null;
|
|
18
|
+
/** Called after every composite. The owner refreshes the viewers mirroring this one. */
|
|
19
|
+
this.onComposited = null;
|
|
24
20
|
// Reusable ImageData buffer for zero-allocation slice rendering
|
|
25
21
|
this._reusableSliceBuffer = null;
|
|
26
22
|
this._reusableBufferWidth = 0;
|
|
@@ -130,22 +126,6 @@ export class RenderingUtils {
|
|
|
130
126
|
return null; // Volume not ready
|
|
131
127
|
}
|
|
132
128
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Populate one cache entry's paths for one render mode.
|
|
135
|
-
*
|
|
136
|
-
* Split out because the two modes are built at different times: whichever is in use when
|
|
137
|
-
* a slice is first drawn, and the other one only if the clinician switches while still on
|
|
138
|
-
* that slice. Building both eagerly would make every slice scrub pay for a mode most
|
|
139
|
-
* sessions never turn on.
|
|
140
|
-
*/
|
|
141
|
-
buildPaths(entry, data, stride, outline) {
|
|
142
|
-
const target = outline ? entry.outlines : entry.fills;
|
|
143
|
-
for (const lbl of entry.labels) {
|
|
144
|
-
target.set(lbl, outline
|
|
145
|
-
? extractLabelOutline(data, entry.W, entry.H, lbl, stride, 0)
|
|
146
|
-
: extractLabelContours(data, entry.W, entry.H, lbl, stride, 0));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
129
|
/**
|
|
150
130
|
* Render a layer's slice onto the target canvas as vector contours.
|
|
151
131
|
*
|
|
@@ -183,96 +163,8 @@ export class RenderingUtils {
|
|
|
183
163
|
const volume = this.getVolumeForLayer(layer);
|
|
184
164
|
if (!volume)
|
|
185
165
|
return;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
// Cache miss → run the expensive extraction once. Hits (zoom,
|
|
189
|
-
// recomposite, contrast toggle) skip straight to the draw below.
|
|
190
|
-
let entry = this._contourCache.get(layer);
|
|
191
|
-
if (!entry || entry.key !== cacheKey) {
|
|
192
|
-
const slice = volume.getSliceUint8(sliceIndex, axis);
|
|
193
|
-
entry = {
|
|
194
|
-
key: cacheKey,
|
|
195
|
-
W: slice.width,
|
|
196
|
-
H: slice.height,
|
|
197
|
-
labels: findLabelsInSlice(slice.data, slice.width, slice.height, stride, 0),
|
|
198
|
-
fills: new Map(),
|
|
199
|
-
outlines: new Map(),
|
|
200
|
-
};
|
|
201
|
-
this._contourCache.set(layer, entry);
|
|
202
|
-
this.buildPaths(entry, slice.data, stride, outline);
|
|
203
|
-
}
|
|
204
|
-
else if ((outline ? entry.outlines : entry.fills).size !== entry.labels.length) {
|
|
205
|
-
// The mode changed since this slice was last drawn, so the other set of
|
|
206
|
-
// paths is cached and this one is not. Re-read the slice and build it; from
|
|
207
|
-
// here on both are present and toggling is a pure cache hit.
|
|
208
|
-
const slice = volume.getSliceUint8(sliceIndex, axis);
|
|
209
|
-
this.buildPaths(entry, slice.data, stride, outline);
|
|
210
|
-
}
|
|
211
|
-
if (entry.labels.length === 0)
|
|
212
|
-
return;
|
|
213
|
-
const { W, H, labels } = entry;
|
|
214
|
-
const paths = outline ? entry.outlines : entry.fills;
|
|
215
|
-
const channelVis = this.state.gui_states.layerChannel.channelVisibility[layer];
|
|
216
|
-
targetCtx.save();
|
|
217
|
-
// Vector drawing — imageSmoothingEnabled is irrelevant here, but keep
|
|
218
|
-
// it off to match the rest of the pipeline.
|
|
219
|
-
targetCtx.imageSmoothingEnabled = false;
|
|
220
|
-
if (outline) {
|
|
221
|
-
// Stroke on an UNTRANSFORMED context, with the voxel→display mapping carried
|
|
222
|
-
// in the path instead. `lineWidth` is then measured in screen pixels, which
|
|
223
|
-
// is what the other two options get wrong: stroking under `ctx.scale(sx, sy)`
|
|
224
|
-
// thickens the line with the zoom, exactly when the clinician has magnified
|
|
225
|
-
// the image to look at the boundary — and because voxels are rarely isotropic
|
|
226
|
-
// (sx !== sy), it also comes out thicker in one axis than the other.
|
|
227
|
-
const matrix = new DOMMatrix();
|
|
228
|
-
if (axis === 'y') {
|
|
229
|
-
matrix.scaleSelf(1, -1);
|
|
230
|
-
matrix.translateSelf(0, -scaledHeight);
|
|
231
|
-
}
|
|
232
|
-
matrix.scaleSelf(scaledWidth / W, scaledHeight / H);
|
|
233
|
-
targetCtx.lineWidth = OUTLINE_WIDTH_PX;
|
|
234
|
-
// Segments are emitted per cell and meet at shared endpoints; round caps
|
|
235
|
-
// close those joins. Canvas composites a whole Path2D in one pass, so the
|
|
236
|
-
// overlap costs no doubled alpha.
|
|
237
|
-
targetCtx.lineJoin = 'round';
|
|
238
|
-
targetCtx.lineCap = 'round';
|
|
239
|
-
for (const lbl of labels) {
|
|
240
|
-
if (channelVis && channelVis[lbl] === false)
|
|
241
|
-
continue;
|
|
242
|
-
const path = paths.get(lbl);
|
|
243
|
-
if (!path)
|
|
244
|
-
continue;
|
|
245
|
-
const color = volume.getChannelColor(lbl);
|
|
246
|
-
targetCtx.strokeStyle =
|
|
247
|
-
`rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
248
|
-
const display = new Path2D();
|
|
249
|
-
display.addPath(path, matrix);
|
|
250
|
-
targetCtx.stroke(display);
|
|
251
|
-
}
|
|
252
|
-
targetCtx.restore();
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
// Coronal (axis='y') Z-flip: mirrors the flip applied by the write
|
|
256
|
-
// path (syncLayerSliceData). Apply BEFORE the voxel→display scale
|
|
257
|
-
// so the flip operates in display coordinates.
|
|
258
|
-
if (axis === 'y') {
|
|
259
|
-
targetCtx.scale(1, -1);
|
|
260
|
-
targetCtx.translate(0, -scaledHeight);
|
|
261
|
-
}
|
|
262
|
-
// Voxel coord (x ∈ [0, W], y ∈ [0, H]) → display coord.
|
|
263
|
-
targetCtx.scale(scaledWidth / W, scaledHeight / H);
|
|
264
|
-
for (const lbl of labels) {
|
|
265
|
-
if (channelVis && channelVis[lbl] === false)
|
|
266
|
-
continue;
|
|
267
|
-
const path = paths.get(lbl);
|
|
268
|
-
if (!path)
|
|
269
|
-
continue;
|
|
270
|
-
const color = volume.getChannelColor(lbl);
|
|
271
|
-
targetCtx.fillStyle =
|
|
272
|
-
`rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
273
|
-
targetCtx.fill(path, 'nonzero');
|
|
274
|
-
}
|
|
275
|
-
targetCtx.restore();
|
|
166
|
+
const entry = contourEntry(this._contourCache, layer, `${axis}:${sliceIndex}:${volume.getVersion()}`, () => (Object.assign(Object.assign({}, volume.getSliceUint8(sliceIndex, axis)), { stride: volume.getChannels() })), outline);
|
|
167
|
+
paintContours(entry, targetCtx, axis, scaledWidth, scaledHeight, outline, (lbl) => volume.getChannelColor(lbl), this.state.gui_states.layerChannel.channelVisibility[layer]);
|
|
276
168
|
}
|
|
277
169
|
catch (_a) {
|
|
278
170
|
// Slice out of bounds or volume not ready — skip silently
|
|
@@ -312,7 +204,7 @@ export class RenderingUtils {
|
|
|
312
204
|
* Only draws layers whose visibility is enabled.
|
|
313
205
|
*/
|
|
314
206
|
compositeAllLayers() {
|
|
315
|
-
var _a, _b;
|
|
207
|
+
var _a, _b, _c, _d;
|
|
316
208
|
const masterCtx = this.state.protectedData.ctxes.drawingLayerMasterCtx;
|
|
317
209
|
const width = this.state.nrrd_states.view.changedWidth;
|
|
318
210
|
const height = this.state.nrrd_states.view.changedHeight;
|
|
@@ -329,6 +221,8 @@ export class RenderingUtils {
|
|
|
329
221
|
masterCtx.restore();
|
|
330
222
|
}
|
|
331
223
|
}
|
|
224
|
+
(_c = this.mirror) === null || _c === void 0 ? void 0 : _c.paint(masterCtx, width, height);
|
|
225
|
+
(_d = this.onComposited) === null || _d === void 0 ? void 0 : _d.call(this);
|
|
332
226
|
}
|
|
333
227
|
}
|
|
334
228
|
//# sourceMappingURL=RenderingUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderingUtils.js","sourceRoot":"","sources":["../../../src/Utils/segmentation/RenderingUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RenderingUtils.js","sourceRoot":"","sources":["../../../src/Utils/segmentation/RenderingUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAqB,MAAM,gBAAgB,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAc;IAyCvB,YAAY,KAAkB;QAtC9B,2DAA2D;QAC3D,uBAAkB,GAAqC,GAAG,EAAE,GAAG,CAAC,CAAC;QAEjE,kGAAkG;QAClG,WAAM,GAAsB,IAAI,CAAC;QAEjC,wFAAwF;QACxF,iBAAY,GAAwB,IAAI,CAAC;QAEzC,gEAAgE;QACxD,yBAAoB,GAAqB,IAAI,CAAC;QAC9C,yBAAoB,GAAW,CAAC,CAAC;QACjC,0BAAqB,GAAW,CAAC,CAAC;QAE1C;;;;;;;;;;;;;;;;;;;;;WAqBG;QACK,kBAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QAGpD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,oEAAoE;IAEpE;;;;;OAKG;IACH,iBAAiB,CAAC,KAAa;QAC3B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ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,MAAA,IAAI,CAAC,YAAY,oDAAI,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RGBAColor } from "./core/types";
|
|
2
|
+
/** One 2D slice of labels: `width × height` cells, `stride` bytes apart, the label at offset 0. */
|
|
3
|
+
export interface LabelSlice {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
stride: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Outline stroke width, in screen pixels.
|
|
11
|
+
*
|
|
12
|
+
* Screen pixels rather than voxels so magnifying the image does not thicken the line over the
|
|
13
|
+
* boundary the clinician magnified it to see. Thin enough to sit on an edge, thick enough to
|
|
14
|
+
* stay visible against bright tissue.
|
|
15
|
+
*/
|
|
16
|
+
export declare const OUTLINE_WIDTH_PX = 1.5;
|
|
17
|
+
/**
|
|
18
|
+
* One slice's contours, in voxel coordinates. Fill and outline paths are built lazily and side
|
|
19
|
+
* by side, so switching mode costs one extraction the first time and is a cache hit after.
|
|
20
|
+
*/
|
|
21
|
+
export interface ContourEntry {
|
|
22
|
+
key: string;
|
|
23
|
+
W: number;
|
|
24
|
+
H: number;
|
|
25
|
+
labels: number[];
|
|
26
|
+
/** Silhouettes, to fill. Built on first use of fill mode for this slice. */
|
|
27
|
+
fills: Map<number, Path2D>;
|
|
28
|
+
/** Boundaries, to stroke. Built on first use of outline mode for this slice. */
|
|
29
|
+
outlines: Map<number, Path2D>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The cached contours for `slot` under `key`, extracting on a miss. One entry per slot: a new
|
|
33
|
+
* key overwrites it. `readSlice` is called only when extraction is needed.
|
|
34
|
+
*/
|
|
35
|
+
export declare function contourEntry(cache: Map<string, ContourEntry>, slot: string, key: string, readSlice: () => LabelSlice, outline: boolean): ContourEntry;
|
|
36
|
+
/** Paint an entry's visible labels onto `targetCtx`, scaled from voxels to `scaledWidth × scaledHeight`. */
|
|
37
|
+
export declare function paintContours(entry: ContourEntry, targetCtx: CanvasRenderingContext2D, axis: "x" | "y" | "z", scaledWidth: number, scaledHeight: number, outline: boolean, colorOf: (label: number) => RGBAColor, channelVis?: Record<number, boolean>): void;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { extractLabelContours, extractLabelOutline, findLabelsInSlice } from "./core/MarchingSquares";
|
|
2
|
+
/**
|
|
3
|
+
* Outline stroke width, in screen pixels.
|
|
4
|
+
*
|
|
5
|
+
* Screen pixels rather than voxels so magnifying the image does not thicken the line over the
|
|
6
|
+
* boundary the clinician magnified it to see. Thin enough to sit on an edge, thick enough to
|
|
7
|
+
* stay visible against bright tissue.
|
|
8
|
+
*/
|
|
9
|
+
export const OUTLINE_WIDTH_PX = 1.5;
|
|
10
|
+
/**
|
|
11
|
+
* Populate one cache entry's paths for one render mode.
|
|
12
|
+
*
|
|
13
|
+
* Split out because the two modes are built at different times: whichever is in use when
|
|
14
|
+
* a slice is first drawn, and the other one only if the clinician switches while still on
|
|
15
|
+
* that slice. Building both eagerly would make every slice scrub pay for a mode most
|
|
16
|
+
* sessions never turn on.
|
|
17
|
+
*/
|
|
18
|
+
function buildPaths(entry, data, stride, outline) {
|
|
19
|
+
const target = outline ? entry.outlines : entry.fills;
|
|
20
|
+
for (const lbl of entry.labels) {
|
|
21
|
+
target.set(lbl, outline
|
|
22
|
+
? extractLabelOutline(data, entry.W, entry.H, lbl, stride, 0)
|
|
23
|
+
: extractLabelContours(data, entry.W, entry.H, lbl, stride, 0));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The cached contours for `slot` under `key`, extracting on a miss. One entry per slot: a new
|
|
28
|
+
* key overwrites it. `readSlice` is called only when extraction is needed.
|
|
29
|
+
*/
|
|
30
|
+
export function contourEntry(cache, slot, key, readSlice, outline) {
|
|
31
|
+
// Cache miss → run the expensive extraction once. Hits (zoom,
|
|
32
|
+
// recomposite, contrast toggle) skip straight to the draw.
|
|
33
|
+
let entry = cache.get(slot);
|
|
34
|
+
if (!entry || entry.key !== key) {
|
|
35
|
+
const slice = readSlice();
|
|
36
|
+
entry = {
|
|
37
|
+
key,
|
|
38
|
+
W: slice.width,
|
|
39
|
+
H: slice.height,
|
|
40
|
+
labels: findLabelsInSlice(slice.data, slice.width, slice.height, slice.stride, 0),
|
|
41
|
+
fills: new Map(),
|
|
42
|
+
outlines: new Map(),
|
|
43
|
+
};
|
|
44
|
+
cache.set(slot, entry);
|
|
45
|
+
buildPaths(entry, slice.data, slice.stride, outline);
|
|
46
|
+
}
|
|
47
|
+
else if ((outline ? entry.outlines : entry.fills).size !== entry.labels.length) {
|
|
48
|
+
// The mode changed since this slice was last drawn, so the other set of
|
|
49
|
+
// paths is cached and this one is not. Re-read the slice and build it; from
|
|
50
|
+
// here on both are present and toggling is a pure cache hit.
|
|
51
|
+
const slice = readSlice();
|
|
52
|
+
buildPaths(entry, slice.data, slice.stride, outline);
|
|
53
|
+
}
|
|
54
|
+
return entry;
|
|
55
|
+
}
|
|
56
|
+
/** Paint an entry's visible labels onto `targetCtx`, scaled from voxels to `scaledWidth × scaledHeight`. */
|
|
57
|
+
export function paintContours(entry, targetCtx, axis, scaledWidth, scaledHeight, outline, colorOf, channelVis) {
|
|
58
|
+
if (entry.labels.length === 0)
|
|
59
|
+
return;
|
|
60
|
+
targetCtx.save();
|
|
61
|
+
// A throw (a missing colour, say) must not leave the transform on the target.
|
|
62
|
+
try {
|
|
63
|
+
drawPaths(entry, targetCtx, axis, scaledWidth, scaledHeight, outline, colorOf, channelVis);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
targetCtx.restore();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function drawPaths(entry, targetCtx, axis, scaledWidth, scaledHeight, outline, colorOf, channelVis) {
|
|
70
|
+
const { W, H, labels } = entry;
|
|
71
|
+
const paths = outline ? entry.outlines : entry.fills;
|
|
72
|
+
// Vector drawing — imageSmoothingEnabled is irrelevant here, but keep
|
|
73
|
+
// it off to match the rest of the pipeline.
|
|
74
|
+
targetCtx.imageSmoothingEnabled = false;
|
|
75
|
+
if (outline) {
|
|
76
|
+
// Stroke on an UNTRANSFORMED context, with the voxel→display mapping carried
|
|
77
|
+
// in the path instead. `lineWidth` is then measured in screen pixels, which
|
|
78
|
+
// is what the other two options get wrong: stroking under `ctx.scale(sx, sy)`
|
|
79
|
+
// thickens the line with the zoom, exactly when the clinician has magnified
|
|
80
|
+
// the image to look at the boundary — and because voxels are rarely isotropic
|
|
81
|
+
// (sx !== sy), it also comes out thicker in one axis than the other.
|
|
82
|
+
const matrix = new DOMMatrix();
|
|
83
|
+
if (axis === "y") {
|
|
84
|
+
matrix.scaleSelf(1, -1);
|
|
85
|
+
matrix.translateSelf(0, -scaledHeight);
|
|
86
|
+
}
|
|
87
|
+
matrix.scaleSelf(scaledWidth / W, scaledHeight / H);
|
|
88
|
+
targetCtx.lineWidth = OUTLINE_WIDTH_PX;
|
|
89
|
+
// Segments are emitted per cell and meet at shared endpoints; round caps
|
|
90
|
+
// close those joins. Canvas composites a whole Path2D in one pass, so the
|
|
91
|
+
// overlap costs no doubled alpha.
|
|
92
|
+
targetCtx.lineJoin = "round";
|
|
93
|
+
targetCtx.lineCap = "round";
|
|
94
|
+
for (const lbl of labels) {
|
|
95
|
+
if (channelVis && channelVis[lbl] === false)
|
|
96
|
+
continue;
|
|
97
|
+
const path = paths.get(lbl);
|
|
98
|
+
if (!path)
|
|
99
|
+
continue;
|
|
100
|
+
const color = colorOf(lbl);
|
|
101
|
+
targetCtx.strokeStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
102
|
+
const display = new Path2D();
|
|
103
|
+
display.addPath(path, matrix);
|
|
104
|
+
targetCtx.stroke(display);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Coronal (axis='y') Z-flip: mirrors the flip applied by the write
|
|
109
|
+
// path (syncLayerSliceData). Apply BEFORE the voxel→display scale
|
|
110
|
+
// so the flip operates in display coordinates.
|
|
111
|
+
if (axis === "y") {
|
|
112
|
+
targetCtx.scale(1, -1);
|
|
113
|
+
targetCtx.translate(0, -scaledHeight);
|
|
114
|
+
}
|
|
115
|
+
// Voxel coord (x ∈ [0, W], y ∈ [0, H]) → display coord.
|
|
116
|
+
targetCtx.scale(scaledWidth / W, scaledHeight / H);
|
|
117
|
+
for (const lbl of labels) {
|
|
118
|
+
if (channelVis && channelVis[lbl] === false)
|
|
119
|
+
continue;
|
|
120
|
+
const path = paths.get(lbl);
|
|
121
|
+
if (!path)
|
|
122
|
+
continue;
|
|
123
|
+
const color = colorOf(lbl);
|
|
124
|
+
targetCtx.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`;
|
|
125
|
+
targetCtx.fill(path, "nonzero");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=contourPaint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contourPaint.js","sourceRoot":"","sources":["../../../src/Utils/segmentation/contourPaint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAUtG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAiBpC;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,KAAmB,EAAE,IAAgB,EAAE,MAAc,EAAE,OAAgB;IACzF,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IACtD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,CACR,GAAG,EACH,OAAO;YACL,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,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C,CAAC;QACvB,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAED,wDAAwD;IACxD,SAAS,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAEnD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,UAAU,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,SAAS;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,SAAS,CAAC,SAAS,GAAG,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;QACnF,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -53,6 +53,11 @@ export class DragSliceTool extends BaseTool {
|
|
|
53
53
|
}
|
|
54
54
|
let newIndex = view.currentSliceIndex + sliceModifyNum;
|
|
55
55
|
if (newIndex != view.currentSliceIndex || view.showContrast) {
|
|
56
|
+
// While a preview slice is shown the displayed slice has depth 1, so moving it would
|
|
57
|
+
// paint blank; the host fetches the target slice instead.
|
|
58
|
+
const target = Math.min(Math.max(newIndex, view.minIndex), view.maxIndex);
|
|
59
|
+
if (this.callbacks.previewSliceMove(target))
|
|
60
|
+
return;
|
|
56
61
|
if (newIndex > view.maxIndex) {
|
|
57
62
|
newIndex = view.maxIndex;
|
|
58
63
|
view.contrastNum = this.ctx.protectedData.displaySlices.length - 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragSliceTool.js","sourceRoot":"","sources":["../../../../src/Ut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AI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,aAAa,WAAW,MAAM,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAC7G,mBAAmB,IAAI,CAAC,iBAAiB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,UAAU,IAAI,CAAC,iBAAiB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;IAED,0BAA0B;QACxB,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,mBAAmB;YACxC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,mBAAmB,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawing another viewer's masks, read live through a voxel-to-voxel transform.
|
|
3
|
+
*
|
|
4
|
+
* The transform is a row-major 4×4 from this viewer's voxel (x, y, z, 1) to the source's
|
|
5
|
+
* voxel. Slices are built in `MaskVolume.getSliceUint8`'s layout for this viewer's own grid,
|
|
6
|
+
* so the source's paint code draws them unchanged, flips included.
|
|
7
|
+
*/
|
|
8
|
+
import type { MaskVolume } from "../core/index";
|
|
9
|
+
import type { CanvasState } from "../CanvasState";
|
|
10
|
+
import { type LabelSlice } from "../contourPaint";
|
|
11
|
+
export type Axis = "x" | "y" | "z";
|
|
12
|
+
/** A slice's width and height for `axis`, as `getSliceUint8` lays it out. */
|
|
13
|
+
export declare function sliceDims(dims: ArrayLike<number>, axis: Axis): [number, number];
|
|
14
|
+
/** Whether `m` is the identity within `tol`. No matrix counts as the identity. */
|
|
15
|
+
export declare function isIdentity(m: ArrayLike<number> | null | undefined, tol?: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The source's labels on this viewer's slice `index` along `axis`. A cell mapping outside
|
|
18
|
+
* the source is 0. On the same grid with the identity, it is the source's own slice.
|
|
19
|
+
*
|
|
20
|
+
* With a diagonal transform (the axes agree, only scale and offset differ), a mirror voxel
|
|
21
|
+
* coarser than the source shows the first label found among every source voxel it spans, so
|
|
22
|
+
* a finding thinner than the mirror's slice still appears on the slice that contains it.
|
|
23
|
+
* Any other transform samples the nearest source voxel.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mirrorSliceLabels(source: MaskVolume, mirrorDims: ArrayLike<number>, axis: Axis, index: number, m: ArrayLike<number> | null): LabelSlice;
|
|
26
|
+
/**
|
|
27
|
+
* One viewer drawing another's masks. Holds no mask data: every paint reads the source's
|
|
28
|
+
* volumes and display state. A new transform means a new instance, so the cache never holds
|
|
29
|
+
* contours from another transform.
|
|
30
|
+
*/
|
|
31
|
+
export declare class MaskMirror {
|
|
32
|
+
private readonly self;
|
|
33
|
+
readonly source: CanvasState;
|
|
34
|
+
private readonly matrix;
|
|
35
|
+
/** One contour entry per source layer, for the slice last painted. */
|
|
36
|
+
private cache;
|
|
37
|
+
/** The source volume each cache entry was built from; a case load replaces the object. */
|
|
38
|
+
private cachedVolumes;
|
|
39
|
+
constructor(self: CanvasState, source: CanvasState, matrix: ArrayLike<number> | null);
|
|
40
|
+
/** Paint every visible source layer onto `ctx` for this viewer's current axis and slice. */
|
|
41
|
+
paint(ctx: CanvasRenderingContext2D, width: number, height: number): void;
|
|
42
|
+
}
|