Short Description

Generate a random colormap for the current active image.

Versions

  • Version 1 • Released on: 2018-12-17 13:56:22
    Download
    Description:

    initial version

    importClass(Packages.icy.image.colormap.IcyColorMap)
    importClass(Packages.icy.util.Random)
    importClass(Packages.icy.util.ColorUtil)
    
    // get all opened view
    viewers = gui.getViewers()
    // get LUT (look up table) from current view
    lut = gui.getActiveLUT()
    
    // current view exist ?
    if (lut != null)
    {
    	// get LUT for first channel
    	lutCh = lut.getLutChannel(0)
    	// get colormap
    	colormap = lutCh.getColorMap()
    	// set colormap to RGB type
    	colormap.setType(IcyColorMap.IcyColorMapType.RGB)
    
    	// generate rainbow colormap with 256 entries
    	colors = ColorUtil.generateRainbow(256)
    
    	// set a random color for each entry of the colormap
    	for(i = 0; i < 256; i++)
    		colormap.setARGB(i, colors[Random.nextInt(256)])
    }
    

Leave a Review