Convert the image of a element to a false color image

@param {HTMLElement} element The Cornerstone element
@param {*} colormap - it can be a colormap object or a colormap id (string)

@returns {void}
482363
function convertToFalseColorImage (element, colormap) {
  const enabledElement = getEnabledElement(element);


  return convertImageToFalseColorImage(enabledElement.image, colormap);
}
36815
function addStyle(element) {
			if (parent.legendScale === null) {
				return false;
			}

			element.attr("fill", function(d) {
				if (d.v === null && (options.hasOwnProperty("considerMissingDataAsZero") && !options.considerMissingDataAsZero)) {
					if (options.legendColors.hasOwnProperty("base")) {
						return options.legendColors.base;
					}
				}

				if (options.legendColors !== null && options.legendColors.hasOwnProperty("empty") &&
					(d.v === 0 || (d.v === null && options.hasOwnProperty("considerMissingDataAsZero") && options.considerMissingDataAsZero))
				) {
					return options.legendColors.empty;
				}

				if (d.v < 0 && options.legend[0] > 0 && options.legendColors !== null && options.legendColors.hasOwnProperty("overflow")) {
					return options.legendColors.overflow;
				}

				return parent.legendScale(Math.min(d.v, options.legend[options.legend.length-1]));
			});
		}
185578
function mungeNonPixel( elem, value ) {
  // IE8 and has percent value
  if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
    return value;
  }
  var style = elem.style;
  // Remember the original values
  var left = style.left;
  var rs = elem.runtimeStyle;
  var rsLeft = rs && rs.left;

  // Put in the new values to get a computed value out
  if ( rsLeft ) {
    rs.left = elem.currentStyle.left;
  }
  style.left = value;
  value = style.pixelLeft;

  // Revert the changed values
  style.left = left;
  if ( rsLeft ) {
    rs.left = rsLeft;
  }

  return value;
}
35580
function(color, alpha){
      var args;
      if (2 == arguments.length) {
        var c = parse(color.trim());
        args = [c.r, c.g, c.b, alpha];
      } else {
        args = [].slice.call(arguments);
      }

      return 'rgba(' + args.join(', ') + ')';
    }
697453
function ColorStop() {
    this.parent = null;
    this.beforeNodes = [];
    this.colorNode = null;
    this.separatorNodes = [];
    this.positionNode = null;
    this.warning = null;
    this.parsePosition();
}
904244
def show_colormap(cls, names=[], N=10, show=True, *args, **kwargs):
        """"""
        names = safe_list(names)
        obj = cls(names, N, *args, **kwargs)
        vbox = obj.layout()
        buttons = QDialogButtonBox(QDialogButtonBox.Close, parent=obj)
        buttons.rejected.connect(obj.close)
        vbox.addWidget(buttons)
        if show:
            obj.show()
        return obj
1042100
def palettize(self, colormap):
        

        if self.mode not in ("L", "LA"):
            raise ValueError("Image should be grayscale to colorize")

        l_data = self.data.sel(bands=['L'])

        def _palettize(data):
            # returns data and palette, only need data
            return colormap.palettize(data)[0]

        new_data = l_data.data.map_blocks(_palettize, dtype=l_data.dtype)
        self.palette = tuple(colormap.colors)

        if self.mode == "L":
            mode = "P"
        else:
            mode = "PA"
            new_data = da.concatenate([new_data, self.data.sel(bands=['A'])], axis=0)

        self.data.data = new_data
        self.data.coords['bands'] = list(mode)
946182
function(color) { 
        if (color != undefined) {
            this.backgroundColor = color; 
        }
        
        if (this.div != null) {
            this.div.style.backgroundColor = this.backgroundColor;
        }
    }
250410
function recolorBillboard(img, color) {
  var canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;

  // Copy the image contents to the canvas
  var context = canvas.getContext("2d");
  context.drawImage(img, 0, 0);
  var image = context.getImageData(0, 0, canvas.width, canvas.height);
  var normClr = [color.red, color.green, color.blue, color.alpha];

  var length = image.data.length; //pixel count * 4
  for (var i = 0; i < length; i += 4) {
    for (var j = 0; j < 4; j++) {
      image.data[j + i] *= normClr[j];
    }
  }

  context.putImageData(image, 0, 0);
  return canvas.toDataURL();
  //    return context.getImageData(0, 0, canvas.width, canvas.height);
}
490702
function ColorPicker() {
  ui.Emitter.call(this);
  this._colorPos = {};
  this.el = $(html);
  this.main = this.el.find('.main').get(0);
  this.spectrum = this.el.find('.spectrum').get(0);
  $(this.main).bind('selectstart', function(e){ e.preventDefault() });
  $(this.spectrum).bind('selectstart', function(e){ e.preventDefault() });
  this.hue(rgb(255, 0, 0));
  this.spectrumEvents();
  this.mainEvents();
  this.w = 180;
  this.h = 180;
  this.render();
}
221486
function() {

            var self = this;
            var $element = $(self.element);

            // TODO: how to visually show the color range?
            // map domain -1 to 5 to color range of hsl(152,80%,80%) 
            // to hsl(228,30%,40%)
            //var color = d3.scale.linear()
            //    .domain([-1, 2])
            //    .range(self.options.colorRange)
            //    .interpolate(d3.interpolateHcl);
            // this is another solution to set the color range for
            // the background color.
            var color = function(depth) {

                // depth -1 will be the background,
                var index = depth < 0 ? 0 : depth;
                // to make sure it is not exceed the color range.
                if(index > self.options.colorRange.length - 1) {
                    index = self.options.colorRange.length - 1;
                }

                return self.options.colorRange[index];
            };

            // TODO: What's pack layout?
            // make pack layout for hierarchal layouts in D3, 
            // (circles within circles)
            var packSize = self.options.diameter - 
                           self.options.margin;
            var pack = d3.layout.pack()
                .padding(2)
                .size([packSize, packSize])
                .value(function(d) { return d.size; })

            // append <g> to <svg> to the <body>
            // crate the container circle as SVG element.
            var selector = "#" + self.attrId;
            self.svg = d3.select(selector).append("svg")
                .attr("width", self.options.diameter)
                .attr("height", self.options.diameter)
                .style("margin", "auto")
                .style("display", "block")
                .append("g")
                .attr("transform", 
                      "translate(" + self.options.diameter / 2 + 
                      "," + self.options.diameter / 2 + ")");

            // request JSON file and process its data (root variable)
            //d3.json(dataFile, function(error, root) {
            //    if (error) return console.error(error);

            // process JSON data in pack layout to 
            // get positions of each node
            var root = self.circleData;
            self.focus = root;
            // TODO: pack nodes function?
            self.nodes = pack.nodes(root);
            console.log(self.nodes);
            self.view = [];

            // selectAll says "map nodes[] to <circle>"; 
            // create <circle> for <g>
            self.circle = self.svg.selectAll("circle")
                .data(self.nodes)
                // .enter() binds new data to new element 
                // (<circle> in this case)
                .enter().append("circle")
                .attr("class", function(d) {
                    return d.parent ? d.children ? "node" : 
                           "node node--leaf" : "node node--root"; 
                })
                .style("fill", function(d) {

                    if (d.children) {
                        // if ccurrent node has children, 
                        // we will set the filling color based on 
                        // the calculation result from color range.
                        return color(d.depth);
                    } else {
                        // return the fill color for leaf.
                        return 'leafFill' in d ? d.leafFill : 
                            self.options.leafFill;
                    }
                })
                .on("click", function(d) {

                    if (self.focus !== d) {
                        self.zoom(d);
                        d3.event.stopPropagation();
                    }
                });

            // create <symbol> to hold <image> for use 
            // with <use> later
            self.svg.selectAll("symbol")
                .data(self.nodes)
                .enter().append("symbol")
                .attr("id", function(d, i) {
                    return self.attrId + "-img-" + i; 
                })
                // 'viewBox' to ensure entire image 
                // shows in different circle size
                .attr("viewBox", function(d) {
                      // viewBox sized to display entire image 
                      // in fixed size parent svg
                      var w = d.imgWidth ? d.imgWidth : 100;
                      var h = d.imgHeight ? d.imgHeight : 100;
                      return "0 0 " + w + " " + h;
                })
                .attr("preserveAspectRatio", "xMaxYMax meet")
                .append("image")
                .attr("xlink:href", function(d) {
                    return d.imgUrl ? d.imgUrl : null;
                })
                .attr("height", "100%")
                .attr("width", "100%");

            // display <symbol> using <use> 
            // (this way the chart works in chrome/IE)
            var image = self.svg.selectAll("use")
                .data(self.nodes)
                .enter().append("use")
                .attr("xlink:href", function(d, i) {
                    return "#" + self.attrId + "-img-" + i; 
                });

            // add <text> (the category labels)
            var text = self.svg.selectAll("text")
                .data(self.nodes)
                .enter().append("text")
                .attr("class", "label")
                .style("fill-opacity", function(d) {
                    return d.parent === root ? 1 : 0;
                })
                .style("display", function(d) {
                    return d.parent === root ? null : "none";
                })
                .text(function(d) { return d.name; });

            // to move <circle>, <text>, <use> 
            // according to zoom (active circle)
            self.node = self.svg.selectAll("circle,text,use");

            d3.select(selector)
                // update background color.
                .style("background", color(-1))
                .on("click", function() { 
                    self.zoom(root); 
                });

            self.zoomTo([root.x, root.y, 
                         root.r * 2 + self.options.margin]);
        }
6640
function (id, type, elem) {
            var self = this;
            var $mapElem = $(elem.mapElem.node);

            // If an HTML link exists for this element, add cursor attributes
            if (elem.options.href) {
                elem.options.attrs.cursor = "pointer";
                if (elem.options.text) elem.options.text.attrs.cursor = "pointer";
            }

            // Set SVG attributes to map element
            elem.mapElem.attr(elem.options.attrs);
            // Set DOM attributes to map element
            $mapElem.attr({
                "data-id": id,
                "data-type": type
            });
            if (elem.options.cssClass !== undefined) {
                $mapElem.addClass(elem.options.cssClass);
            }

            // Init the label related to the element
            if (elem.options.text && elem.options.text.content !== undefined) {
                // Set a text label in the area
                var textPosition = self.getTextPosition(elem.mapElem.getBBox(), elem.options.text.position, elem.options.text.margin);
                elem.options.text.attrs.text = elem.options.text.content;
                elem.options.text.attrs.x = textPosition.x;
                elem.options.text.attrs.y = textPosition.y;
                elem.options.text.attrs['text-anchor'] = textPosition.textAnchor;
                // Draw text
                elem.textElem = self.paper.text(textPosition.x, textPosition.y, elem.options.text.content);
                // Apply SVG attributes to text element
                elem.textElem.attr(elem.options.text.attrs);
                // Apply DOM attributes
                $(elem.textElem.node).attr({
                    "data-id": id,
                    "data-type": type + '-text'
                });
            }

            // Set user event handlers
            if (elem.options.eventHandlers) self.setEventHandlers(id, type, elem);

            // Set hover option for mapElem
            self.setHoverOptions(elem.mapElem, elem.options.attrs, elem.options.attrsHover);

            // Set hover option for textElem
            if (elem.textElem) self.setHoverOptions(elem.textElem, elem.options.text.attrs, elem.options.text.attrsHover);
        }
770139
function ( color, parse ) {
            var type = this.type( color, 'color.toRgb() : "' + color + '" ' + MSG_NOT_COLOR ),
                objColor;
    
            switch ( type ) {
                case 'rgb':
                    return parse? this.parseRgba( color ) : color;
                    break;
                case 'rgba':
                    objColor = this.parseRgba( color );
                    break;
                case 'hsl':
                case 'hsla':
                    objColor = this.hslToRgb( color, true );
                    break;
                case 'keyword':
                    color = this.keyword( color, 'color.toRgb() : "' + color + '" ' + MSG_NOT_COLOR );
                case 'hex':
                    objColor = this.hexToRgb( color, true );
                    break;
            }
    
            return parse? objColor : 'rgb(' + objColor.r + ', ' + objColor.g + ', ' + objColor.b + ')';
        }
528949
function(win, elems) {
				var i,
					mode = svgCanvas.getMode();
				if (mode === 'select') {
					setSelectMode();
				}

				for (i = 0; i < elems.length; ++i) {
					var elem = elems[i];

					// if the element changed was the svg, then it could be a resolution change
					if (elem && elem.tagName === 'svg') {
						populateLayers();
						updateCanvas();
					}
					// Update selectedElement if element is no longer part of the image.
					// This occurs for the text elements in Firefox
					else if (elem && selectedElement && selectedElement.parentNode == null) {
//						|| elem && elem.tagName == "path" && !multiselected) { // This was added in r1430, but not sure why
						selectedElement = elem;
					}
				}

				Editor.showSaveWarning = true;

				// we update the contextual panel with potentially new
				// positional/sizing information (we DON'T want to update the
				// toolbar here as that creates an infinite loop)
				// also this updates the history buttons

				// we tell it to skip focusing the text control if the
				// text element was previously in focus
				updateContextPanel();

				// In the event a gradient was flipped:
				if (selectedElement && mode === 'select') {
					paintBox.fill.update();
					paintBox.stroke.update();
				}

				svgCanvas.runExtensions('elementChanged', {
					elems: elems
				});
			}
404162
function checkColorMode() {
    if (angular.isUndefined(usesRGBA)) {
      var testerElement = compile('<div md-colors="{background: \'red\'}" >');
      usesRGBA = testerElement[0].style.background.indexOf('rgba') === 0;
    }
  }
156166
private static IRenderingElement recolor(IRenderingElement element, Color color) {
        if (element instanceof ElementGroup) {
            ElementGroup orgGroup = (ElementGroup) element;
            ElementGroup newGroup = new ElementGroup();
            for (IRenderingElement child : orgGroup) {
                newGroup.add(recolor(child, color));
            }
            return newGroup;
        } else if (element instanceof LineElement) {
            LineElement lineElement = (LineElement) element;
            return new LineElement(lineElement.firstPointX, lineElement.firstPointY, lineElement.secondPointX,
                    lineElement.secondPointY, lineElement.width, color);
        } else if (element instanceof GeneralPath) {
            return ((GeneralPath) element).recolor(color);
        }
        throw new IllegalArgumentException("Cannot highlight rendering element, " + element.getClass());
    }
50422
function(ui)
              {
                switch (settings.color.mode)
                {
                  case 'h':
                    setBG.call($this, colorMapDiv, new Color({ h: ui.val('h') || 0, s: 100, v: 100 }).val('hex'));
                    break;
                  case 's':
                  case 'a':
                    var s = ui.val('s');
                    setAlpha.call($this, colorMapL2, 100 - (s != null ? s : 100));
                    break;
                  case 'v':
                    var v = ui.val('v');
                    setAlpha.call($this, colorMapL1, v != null ? v : 100);
                    break;
                  case 'r':
                    setAlpha.call($this, colorMapL2, Math.precision((ui.val('r') || 0) / 255 * 100, 4));
                    break;
                  case 'g':
                    setAlpha.call($this, colorMapL2, Math.precision((ui.val('g') || 0) / 255 * 100, 4));
                    break;
                  case 'b':
                    setAlpha.call($this, colorMapL2, Math.precision((ui.val('b') || 0) / 255 * 100));
                    break;
                }
                var a = ui.val('a');
                setAlpha.call($this, colorMapL3, Math.precision(((255 - (a || 0)) * 100) / 255, 4));
              }