@@ -22,6 +22,7 @@ function(Layer, segmentation, morph) {
22
22
if ( typeof imageURL !== "string" )
23
23
throw "Invalid imageURL" ;
24
24
this . colormap = options . colormap || [ [ 255 , 255 , 255 ] , [ 255 , 0 , 0 ] ] ;
25
+ this . boundaryColor = options . boundaryColor || [ 255 , 255 , 255 ] ;
25
26
this . boundaryAlpha = options . boundaryAlpha || 127 ;
26
27
this . visualizationAlpha = options . visualizationAlpha || 144 ;
27
28
this . highlightAlpha = options . highlightAlpha ||
@@ -354,8 +355,8 @@ function(Layer, segmentation, morph) {
354
355
var boundaryLayer = this . layers . boundary ;
355
356
boundaryLayer . copy ( this . layers . superpixel ) ;
356
357
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 )
359
360
} ) ;
360
361
boundaryLayer . render ( ) ;
361
362
} ;
@@ -423,23 +424,33 @@ function(Layer, segmentation, morph) {
423
424
Annotator . prototype . _updateHighlight = function ( pixels ) {
424
425
var visualizationData = this . layers . visualization . imageData . data ,
425
426
boundaryData = this . layers . boundary . imageData . data ,
427
+ annotationData = this . layers . annotation . imageData . data ,
426
428
i ,
429
+ color ,
427
430
offset ;
428
431
if ( this . currentPixels !== null ) {
429
432
for ( i = 0 ; i < this . currentPixels . length ; ++ i ) {
430
433
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 ] ;
431
438
visualizationData [ offset + 3 ] = this . visualizationAlpha ;
432
- if ( boundaryData [ offset + 3 ] )
433
- boundaryData [ offset + 3 ] = this . boundaryAlpha ;
434
439
}
435
440
}
436
441
this . currentPixels = pixels ;
437
442
if ( this . currentPixels !== null ) {
438
443
for ( i = 0 ; i < pixels . length ; ++ i ) {
439
444
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
+ }
443
454
}
444
455
}
445
456
this . layers . visualization . render ( ) ;
0 commit comments