ij.process.LUT Java Examples

The following examples show how to use ij.process.LUT. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Renderer3D.java    From 3Dscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void resetRenderingSettings(ExtendedRenderingState rs) {
	LUT[] luts = image.isComposite() ?
			image.getLuts() : new LUT[] {image.getProcessor().getLut()};
	Color[] channelColors = calculateChannelColors();
	for(int c = 0; c < luts.length; c++) {
		rs.setChannelProperty(c, ExtendedRenderingState.INTENSITY_MIN,   luts[c].min);
		rs.setChannelProperty(c, ExtendedRenderingState.INTENSITY_MAX,   luts[c].max);
		rs.setChannelProperty(c, ExtendedRenderingState.INTENSITY_GAMMA, 1);
		rs.setChannelProperty(c, ExtendedRenderingState.ALPHA_MIN,   luts[c].min);
		rs.setChannelProperty(c, ExtendedRenderingState.ALPHA_MAX,   luts[c].max);
		rs.setChannelProperty(c, ExtendedRenderingState.ALPHA_GAMMA, 2);
		rs.setChannelProperty(c, ExtendedRenderingState.WEIGHT, 1);
		rs.setChannelProperty(c, ExtendedRenderingState.CHANNEL_COLOR_RED,   channelColors[c].getRed());
		rs.setChannelProperty(c, ExtendedRenderingState.CHANNEL_COLOR_GREEN, channelColors[c].getGreen());
		rs.setChannelProperty(c, ExtendedRenderingState.CHANNEL_COLOR_BLUE,  channelColors[c].getBlue());
		rs.setChannelProperty(c, ExtendedRenderingState.USE_LIGHT, 0);
		rs.setChannelProperty(c, ExtendedRenderingState.LIGHT_K_OBJECT,   1);
		rs.setChannelProperty(c, ExtendedRenderingState.LIGHT_K_DIFFUSE,  0);
		rs.setChannelProperty(c, ExtendedRenderingState.LIGHT_K_SPECULAR, 0);
		rs.setChannelProperty(c, ExtendedRenderingState.LIGHT_SHININESS,  5);
		// rs.setChannelProperty(c, ExtendedRenderingState.USE_LUT, 0);
		// TODO useLUT (for now, just leave it as it is)
	}
	rs.setNonChannelProperty(ExtendedRenderingState.RENDERING_ALGORITHM, RenderingAlgorithm.INDEPENDENT_TRANSPARENCY.ordinal());
}
 
Example #2
Source File: Renderer3D.java    From 3Dscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Color[] calculateChannelColors() {
	int nChannels = image.getNChannels();
	Color[] channelColors = new Color[nChannels];
	if(!image.isComposite()) {
		LUT lut = image.getProcessor().getLut();
		if(lut != null) {
			channelColors[0] = getLUTColor(lut);
		} else {
			channelColors[0] = Color.WHITE;
		}
		return channelColors;
	}
	for(int c = 0; c < image.getNChannels(); c++) {
		image.setC(c + 1);
		channelColors[c] = getLUTColor(((CompositeImage)image).getChannelLut());
	}
	return channelColors;
}
 
Example #3
Source File: BDVRenderer.java    From 3Dscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void transferChannelSettings(final CompositeImage ci, final SetupAssignments setupAssignments,
		final VisibilityAndGrouping visibility) {
	final int nChannels = ci.getNChannels();
	final int mode = ci.getCompositeMode();
	final boolean transferColor = mode == IJ.COMPOSITE || mode == IJ.COLOR;
	for (int c = 0; c < nChannels; ++c) {
		final LUT lut = ci.getChannelLut(c + 1);
		final ConverterSetup setup = setupAssignments.getConverterSetups().get(c);
		if (transferColor)
			setup.setColor(new ARGBType(lut.getRGB(255)));
		setup.setDisplayRange(lut.min, lut.max);
	}
	if (mode == IJ.COMPOSITE) {
		final boolean[] activeChannels = ci.getActiveChannels();
		visibility.setDisplayMode(DisplayMode.FUSED);
		for (int i = 0; i < activeChannels.length; ++i)
			visibility.setSourceActive(i, activeChannels[i]);
	} else
		visibility.setDisplayMode(DisplayMode.SINGLE);
	visibility.setCurrentSource(ci.getChannel() - 1);
}
 
Example #4
Source File: GeodesicDistanceMap3DPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
private LUT createFireLUTBlackEnding(double maxVal)
{
	byte[] red = new byte[256];
	byte[] green = new byte[256];
	byte[] blue = new byte[256];

	// initialize LUT with Fire colors
	byte[][] lut = ColorMaps.createJetLut(255);
	for (int i = 0; i < 255; i++)
	{
		red[i] 		= lut[i][0];
		green[i] 	= lut[i][1];
		blue[i] 	= lut[i][2];
	}
	
	// use black as last color (background)
	red[255] = 0;
	green[255] = 0;
	blue[255] = 0;

	// create color model
	IndexColorModel cm = new IndexColorModel(8, 256, red, green, blue);
	return new LUT(cm, 0, maxVal);
}
 
Example #5
Source File: InteractiveGeodesicDistanceMap.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create fire look-up table
 * @param maxVal maximum intensity value
 * @return fire look-up table
 */
private LUT createFireLUT(double maxVal)
{
	byte[][] lut = ColorMaps.createFireLut(256);
	byte[] red = new byte[256];
	byte[] green = new byte[256];
	byte[] blue = new byte[256];
	for (int i = 0; i < 256; i++)
	{
		red[i] 		= lut[i][0];
		green[i] 	= lut[i][1];
		blue[i] 	= lut[i][2];
	}
	IndexColorModel cm = new IndexColorModel(8, 256, red, green, blue);
	return new LUT(cm, 0, maxVal);
}
 
Example #6
Source File: Renderer3D.java    From 3Dscript with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Color getLUTColor(LUT lut) {
	int index = lut.getMapSize() - 1;
	int r = lut.getRed(index);
	int g = lut.getGreen(index);
	int b = lut.getBlue(index);
	return new Color(r, g, b);
}
 
Example #7
Source File: DummyCudaRaycaster.java    From 3Dscript with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Color getLUTColor(LUT lut) {
	int index = lut.getMapSize() - 1;
	int r = lut.getRed(index);
	int g = lut.getGreen(index);
	int b = lut.getBlue(index);
	//IJ.log(index+" "+r+" "+g+" "+b);
	if (r<100 || g<100 || b<100)
		return new Color(r, g, b);
	else
		return Color.black;
}
 
Example #8
Source File: AbstractRendering.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
private void setupLuts() {
    if(image.isComposite()) {
        CompositeImage image2 = (CompositeImage) image;
        LUT[] channeLuts = new LUT[zSlices];
        if (colorizationLut == null) {  // fallback if no LUTs are installed
            for (int i = 0; i < channeLuts.length; i++) {
                //Colormap for slices: (has constant grayscale intensity, unlike jet and similar)
                //r:      /
                //     __/
                //g:    /\
                //     /  \
                //b:   \
                //      \__
                float norm = (float) i / zSlices;
                float r, g, b;
                if (norm < 0.5) {
                    b = 1 - 2 * norm;
                    g = 2 * norm;
                    r = 0;
                } else {
                    b = 0;
                    g = -2 * norm + 2;
                    r = 2 * norm - 1;
                }
                channeLuts[i] = LUT.createLutFromColor(new Color(r, g, b));
            }
        } else {
            int[] rgb = new int[4];
            for (int i = 0; i < channeLuts.length; i++) {
                colorizationLut.getComponents((int)(((float) i / zSlices) * 255f), rgb, 0);
                channeLuts[i] = LUT.createLutFromColor(new Color(rgb[0], rgb[1], rgb[2]));
            }
        }
        image2.setLuts(channeLuts);
    }
}
 
Example #9
Source File: LutPicker.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
private void initialize() {
    String path = IJ.getDirectory("luts");
    List<File> files = IOUtils.listFilesInFolder(new File(path), false);
    luts = new HashMap<String, LUT>();
    for (File f : files) {
        if (FilenameUtils.getExtension(f.getName()).toLowerCase().equals("lut")) {
            String lutName = FilenameUtils.removeExtension(f.getName()).replace('_', ' ');
            LUT lut = LutLoader.openLut(f.getAbsolutePath());
            luts.put(lutName, lut);
            model.addElement(lutName);
        }
    }
}
 
Example #10
Source File: GeodesicDistanceMapPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private LUT createFireLUT(double maxVal)
{
	byte[][] lut = ColorMaps.createFireLut(256);
	byte[] red = new byte[256];
	byte[] green = new byte[256];
	byte[] blue = new byte[256];
	for (int i = 0; i < 256; i++)
	{
		red[i] 		= lut[i][0];
		green[i] 	= lut[i][1];
		blue[i] 	= lut[i][2];
	}
	IndexColorModel cm = new IndexColorModel(8, 256, red, green, blue);
	return new LUT(cm, 0, maxVal);
}
 
Example #11
Source File: MorphologicalSegmentation.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Update the overlay in the display image based on 
 * the current result and slice
 */
void updateResultOverlay() 
{
	if( null != resultImage )
	{
		int slice = displayImage.getCurrentSlice();

		final String displayOption = (String) resultDisplayList.getSelectedItem();							

		ImageRoi roi = null;
		
		if( displayOption.equals( catchmentBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidDamsText ) )				
		{
			ImageProcessor lines = BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) );
			lines.invert();
			lines.setLut( LUT.createLutFromColor( Color.red ) );
			roi = new ImageRoi( 0, 0, lines );
			roi.setZeroTransparent( true );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( watershedLinesText ) )
		{
			roi = new ImageRoi(0, 0, BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidBasinsText ) )	
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( opacity );
		}
										
		displayImage.setOverlay( new Overlay( roi ) );
	}
}
 
Example #12
Source File: InteractiveMarkerControlledWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Update the overlay in the display image based on
 * the current result and slice
 */
void updateResultOverlay()
{
	if( null != resultImage )
	{
		int slice = displayImage.getCurrentSlice();

		final String displayOption = (String) resultDisplayList.getSelectedItem();

		ImageRoi roi = null;

		if( displayOption.equals( catchmentBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidDamsText ) )
		{
			ImageProcessor lines = BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) );
			lines.invert();
			lines.setLut( LUT.createLutFromColor( Color.red ) );
			roi = new ImageRoi( 0, 0, lines );
			roi.setZeroTransparent( true );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( watershedLinesText ) )
		{
			roi = new ImageRoi(0, 0, BinaryImages.binarize( resultImage.getImageStack().getProcessor( slice ) ) );
			roi.setOpacity( 1.0 );
		}
		else if( displayOption.equals( overlaidBasinsText ) )
		{
			roi = new ImageRoi(0, 0, resultImage.getImageStack().getProcessor( slice ) );
			roi.setOpacity( opacity );
		}

		displayImage.setOverlay( new Overlay( roi ) );
	}
}
 
Example #13
Source File: GeodesicDistanceMap3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private LUT createFireLUT(double maxVal)
{
	byte[][] lut = ColorMaps.createFireLut(256);
	byte[] red = new byte[256];
	byte[] green = new byte[256];
	byte[] blue = new byte[256];
	for (int i = 0; i < 256; i++)
	{
		red[i] 		= lut[i][0];
		green[i] 	= lut[i][1];
		blue[i] 	= lut[i][2];
	}
	IndexColorModel cm = new IndexColorModel(8, 256, red, green, blue);
	return new LUT(cm, 0, maxVal);
}
 
Example #14
Source File: Renderer3D.java    From 3Dscript with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ExtendedRenderingState makeDefaultRenderingState(ImagePlus image) {
	LUT[] luts = image.isComposite() ?
			image.getLuts() : new LUT[] {image.getProcessor().getLut()};

	final int nC = image.getNChannels();

	float[] pdIn = new float[] {
			(float)image.getCalibration().pixelWidth,
			(float)image.getCalibration().pixelHeight,
			(float)image.getCalibration().pixelDepth
	};

	Calibration cal = image.getCalibration();
	float pwOut = (float)(image.getWidth()  * cal.pixelWidth  / wOut);
	float phOut = (float)(image.getHeight() * cal.pixelHeight / hOut);
	float pdOut = pdIn[2];
	float[] p = new float[] {pwOut, phOut, pdOut};

	float near = (float)CroppingPanel.getNear(image);
	float far  = (float)CroppingPanel.getFar(image);
	float[] rotcenter = new float[] {
			image.getWidth()   * pdIn[0] / 2,
			image.getHeight()  * pdIn[1] / 2,
			image.getNSlices() * pdIn[2] / 2};

	RenderingSettings[] renderingSettings = new RenderingSettings[nC];
	for(int c = 0; c < nC; c++) {
		renderingSettings[c] = new RenderingSettings(
				(float)luts[c].min, (float)luts[c].max, 1,
				(float)luts[c].min, (float)luts[c].max, 2,
				1,
				0, 0, 0,
				image.getWidth(), image.getHeight(), image.getNSlices(),
				near, far);
	}
	Color[] channelColors = calculateChannelColors();

	CombinedTransform transformation = new CombinedTransform(pdIn, p, rotcenter);

	ExtendedRenderingState rs = new ExtendedRenderingState(0,
			image.getT(),
			renderingSettings,
			channelColors,
			Color.BLACK,
			RenderingAlgorithm.INDEPENDENT_TRANSPARENCY,
			transformation);
	rs.setScalebarProperties(super.getScalebar());
	rs.setBoundingboxProperties(super.getBoundingBox());
	return rs;
}
 
Example #15
Source File: AbstractRendering.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
public BuilderType colorizationLUT(LUT lut) {
    this.colorizationLut = lut;
    return (BuilderType) this;
}
 
Example #16
Source File: LutPicker.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
public LUT getLut(String lut) {
    return luts.get(lut);
}