Java Code Examples for bdv.tools.brightness.ConverterSetup#setColor()

The following examples show how to use bdv.tools.brightness.ConverterSetup#setColor() . 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: 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 2
Source File: BDVRenderer.java    From 3Dscript with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public ImageProcessor render(RenderingState kf) {
	BDVRenderingState bkf = (BDVRenderingState)kf;
	ViewerPanel panel = viewer.getViewer();
	ViewerState state = panel.getState();

	SetupAssignments setupAssignments = viewer.getSetupAssignments();
	for(int s = 0; s < state.numSources(); s++) {
		final ConverterSetup setup = setupAssignments.getConverterSetups().get(s);
		setup.setColor(new ARGBType(bkf.getChannelColor(s).getRGB()));
		setup.setDisplayRange(bkf.getChannelMin(s), bkf.getChannelMax(s));
	}

	DisplayMode displaymode = bkf.getDisplayMode();
	Interpolation interpolation = bkf.getInterpolation();
	int timepoint = bkf.getTimepoint();
	int currentSource = bkf.getCurrentSource();

	panel.setDisplayMode(displaymode);
	if(state.getInterpolation() != interpolation)
		panel.toggleInterpolation();
	panel.setTimepoint(timepoint);
	panel.getVisibilityAndGrouping().setCurrentSource(currentSource);

	CombinedTransform transform = kf.getFwdTransform();

	float[] tmp = calculateForwardTransform(transform);


	int w = panel.getWidth();
	int h = panel.getHeight();

	double rw = 2 * rotationCenter[0];
	double rh = 2 * rotationCenter[1];
	double scaleX = w / rw;
	double scaleY = h / rh;
	double scale = Math.min(scaleX, scaleY);
	rw = rw * scale;
	rh = rh * scale;
	double tx = (w - rw) / 2;
	double ty = (h - rh) / 2;

	AffineTransform3D affine = new AffineTransform3D();

	affine.set(toDouble(tmp));

	affine.scale(scale);
	affine.translate(tx, ty, 0);

	panel.setCurrentViewerTransform(affine);

	return takeSnapshot().getProcessor();
}