Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 8860e12

Browse files
committed
Changed boundary highlight
1 parent b656338 commit 8860e12

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

js/helper/segment-annotator.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function(Layer, segmentation, morph) {
2222
if (typeof imageURL !== "string")
2323
throw "Invalid imageURL";
2424
this.colormap = options.colormap || [[255, 255, 255], [255, 0, 0]];
25+
this.boundaryColor = options.boundaryColor || [255, 255, 255];
2526
this.boundaryAlpha = options.boundaryAlpha || 127;
2627
this.visualizationAlpha = options.visualizationAlpha || 144;
2728
this.highlightAlpha = options.highlightAlpha ||
@@ -354,8 +355,8 @@ function(Layer, segmentation, morph) {
354355
var boundaryLayer = this.layers.boundary;
355356
boundaryLayer.copy(this.layers.superpixel);
356357
boundaryLayer.computeEdgemap({
357-
foreground: [255, 255, 255, this.boundaryAlpha],
358-
background: [255, 255, 255, 0]
358+
foreground: this.boundaryColor.concat(this.boundaryAlpha),
359+
background: this.boundaryColor.concat(0)
359360
});
360361
boundaryLayer.render();
361362
};
@@ -423,23 +424,33 @@ function(Layer, segmentation, morph) {
423424
Annotator.prototype._updateHighlight = function (pixels) {
424425
var visualizationData = this.layers.visualization.imageData.data,
425426
boundaryData = this.layers.boundary.imageData.data,
427+
annotationData = this.layers.annotation.imageData.data,
426428
i,
429+
color,
427430
offset;
428431
if (this.currentPixels !== null) {
429432
for (i = 0; i < this.currentPixels.length; ++i) {
430433
offset = this.currentPixels[i];
434+
color = this.colormap[_getEncodedLabel(annotationData, offset)];
435+
visualizationData[offset + 0] = color[0];
436+
visualizationData[offset + 1] = color[1];
437+
visualizationData[offset + 2] = color[2];
431438
visualizationData[offset + 3] = this.visualizationAlpha;
432-
if (boundaryData[offset + 3])
433-
boundaryData[offset + 3] = this.boundaryAlpha;
434439
}
435440
}
436441
this.currentPixels = pixels;
437442
if (this.currentPixels !== null) {
438443
for (i = 0; i < pixels.length; ++i) {
439444
offset = pixels[i];
440-
visualizationData[offset + 3] = this.highlightAlpha;
441-
if (boundaryData[offset + 3])
442-
boundaryData[offset + 3] = this.highlightAlpha;
445+
if (boundaryData[offset + 3]) {
446+
visualizationData[offset + 0] = this.boundaryColor[0];
447+
visualizationData[offset + 1] = this.boundaryColor[1];
448+
visualizationData[offset + 2] = this.boundaryColor[2];
449+
visualizationData[offset + 3] = this.highlightAlpha;
450+
}
451+
else {
452+
visualizationData[offset + 3] = this.highlightAlpha;
453+
}
443454
}
444455
}
445456
this.layers.visualization.render();

0 commit comments

Comments
 (0)