net.imglib2.view.composite.RealComposite Java Examples

The following examples show how to use net.imglib2.view.composite.RealComposite. 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: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
final static protected < S extends RealType< S >, T extends RealType< T > > void mapComposite(
		final IterableInterval< RealComposite< S > > image,
		final IterableInterval< RealComposite< T > > coefficients )
{
	final Cursor< RealComposite< S > > cs = image.cursor();
	final Cursor< RealComposite< T > > ct = coefficients.cursor();

	while ( cs.hasNext() )
	{
		final RealComposite< S > c = cs.next();
		final RealComposite< T > t = ct.next();

		for ( final S s : c )
			s.setReal( s.getRealDouble() * t.get( 0 ).getRealDouble() + t.get( 1 ).getRealDouble() );
	}
}
 
Example #2
Source File: ConsensusWarpFieldBuilder.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param  interpolatorFactory  factory to include in the returned warp field.
 *
 * @return a warp field built from this builder's consensus set data.
 *         The returned field will utilize the specified interpolator factory.
 */
public AffineWarpField build(final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> interpolatorFactory) {

    final int[] modelIndexGrid = buildModelIndexGrid();

    final AffineWarpField affineWarpField =
            new AffineWarpField(width, height, rowCount, columnCount, interpolatorFactory);

    for (int row = 0; row < rowCount; row++) {
        for (int column = 0; column < columnCount; column++) {

            final int gridIndex = (row * rowCount) + column;
            final int modelIndex = modelIndexGrid[gridIndex];
            final Affine2D model = consensusSetModelList.get(modelIndex);

            final double[] affineMatrixElements = new double[6];
            model.toArray(affineMatrixElements);

            affineWarpField.set(row, column, affineMatrixElements);
        }
    }

    return affineWarpField;
}
 
Example #3
Source File: AffineWarpFieldTransform.java    From render with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void applyInPlace(final double[] location) {

    final double[] warpFieldLocation = { location[0] - locationOffsets[0], location[1] - locationOffsets[1] };

    warpFieldAccessor.setPosition(warpFieldLocation);
    final RealComposite<DoubleType> coefficients = warpFieldAccessor.get();

    final double m00 = coefficients.get(0).getRealDouble();
    final double m10 = coefficients.get(1).getRealDouble();
    final double m01 = coefficients.get(2).getRealDouble();
    final double m11 = coefficients.get(3).getRealDouble();
    final double m02 = coefficients.get(4).getRealDouble();
    final double m12 = coefficients.get(5).getRealDouble();

    // stolen from AffineModel2D.applyInPlace
    final double l0 = location[0];
    location[0] = l0 * m00 + location[1] * m01 + m02;
    location[1] = l0 * m10 + location[1] * m11 + m12;
}
 
Example #4
Source File: N5OpenSourceDialog.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <T extends RealType<T> & NativeType<T>, V extends AbstractVolatileRealType<T, V> & NativeType<V>> void
addRaw(
		final String name,
		final int[] channelSelection,
		final GenericBackendDialogN5 dataset,
		PainteraBaseView viewer) throws Exception {
	final DatasetAttributes attributes = dataset.getAttributes();
	if (attributes.getNumDimensions() == 4)
	{
		LOG.debug("4-dimensional data, assuming channel index at {}", 3);
		final List<? extends SourceState<RealComposite<T>, VolatileWithSet<RealComposite<V>>>> channels = dataset.getChannels(
				name,
				channelSelection,
				viewer.getQueue(),
				viewer.getQueue().getNumPriorities() - 1);
		LOG.debug("Got {} channel sources", channels.size());
		InvokeOnJavaFXApplicationThread.invoke(() -> channels.forEach(viewer::addState));
		LOG.debug("Added {} channel sources", channels.size());
	}
	else {
		final SourceState<T, V> raw = dataset.getRaw(name, viewer.getQueue(), viewer.getQueue().getNumPriorities() - 1);
		LOG.debug("Got raw: {}", raw);
		InvokeOnJavaFXApplicationThread.invoke(() -> viewer.addState(raw));
	}
}
 
Example #5
Source File: AffineWarpFieldTransform.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Appends serialization of this transform's offsets and warp field to the specified data string.
 *
 * @param  data             target data string.
 */
private void serializeWarpField(final StringBuilder data) {
    data.append(locationOffsets[0]).append(' ').append(locationOffsets[1]).append(' ');
    data.append(affineWarpField.getWidth()).append(' ').append(affineWarpField.getHeight()).append(' ');
    data.append(affineWarpField.getRowCount()).append(' ').append(affineWarpField.getColumnCount()).append(' ');
    final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> factory =
            affineWarpField.getInterpolatorFactory();
    data.append(factory.getClass().getCanonicalName()).append(' ');
    final double[] values = affineWarpField.getValues();
    if (values.length < 64) { // skip encoding for smaller fields to simplify visual inspection and testing
        data.append(NO_ENCODING);
        for (final double value : values) {
            data.append(' ').append(value);
        }
    } else {
        data.append(BASE_64_ENCODING).append(' ').append(DoubleArrayConverter.encodeBase64(values));
    }
}
 
Example #6
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <T extends RealType<T>> RandomAccessible<RealComposite<T>>  collapseDimension(
		final RandomAccessibleInterval<T> rai,
		final int dimension,
		final long[] channels,
		final T extension
)
{
	final int lastDim = rai.numDimensions() - 1;
	final int numChannels = (int) rai.dimension(dimension);

	long[] min = Intervals.minAsLongArray(rai);
	long[] max = Intervals.maxAsLongArray(rai);

	assert LongStream.of(channels).filter(c -> c > max[dimension] && c < min[dimension]).count() == 0;

	final RandomAccessibleInterval<T> relevantRai = isFullRange(channels, numChannels)
			? rai
			: Views.stack(LongStream.of(channels).mapToObj(channel -> Views.hyperSlice(rai, dimension, channel)).collect(Collectors.toList()));

	final RandomAccessible<T> ra = Views.extendValue(lastDim == dimension
			? relevantRai
			: Views.moveAxis(relevantRai, dimension, lastDim), extension);
	return Views.collapseReal(ra, numChannels);
}
 
Example #7
Source File: AffineWarpField.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Logic stolen from
 * <a href='https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/org/janelia/intensity/LinearIntensityMap.java'>
 *   TrakEM2 LinearIntensityMap
 * </a>.
 *
 * @return an accessor for deriving warped pixel intensities.
 */
public RealRandomAccess<RealComposite<DoubleType>> getAccessor() {

    final ArrayImg<DoubleType, DoubleArray> warpField =
            ArrayImgs.doubles(values, columnCount, rowCount, VALUES_PER_AFFINE);

    final CompositeIntervalView<DoubleType, RealComposite<DoubleType>>
            collapsedSource = Views.collapseReal(warpField);

    final RandomAccessible<RealComposite<DoubleType>> extendedCollapsedSource = Views.extendBorder(collapsedSource);
    final RealRandomAccessible<RealComposite<DoubleType>> coefficients =
            Views.interpolate(extendedCollapsedSource, interpolatorFactory);

    final double xScale = getXScale();
    final double yScale = getYScale();
    final double[] scale = { xScale, yScale };
    final double[] shift = { 0.5 * xScale , 0.5 * yScale };

    final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation(scale, shift);

    final RealRandomAccessible<RealComposite<DoubleType>> stretchedCoefficients =
            RealViews.transform(coefficients, scaleAndTranslation);

    return stretchedCoefficients.realRandomAccess();
}
 
Example #8
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>, T extends RealType<T>> RealComposite<T>  createExtension(
		final D d,
		final T t,
		final Converter<D, T> converter,
		final long size,
		IntFunction<D> valueAtIndex
)
{
	LOG.debug("Creating extension with size {}", size);
	final ArrayImg<D, ?> img = new ArrayImgFactory<>(d).create(1, size);
	img.setLinkedType((D) d.getNativeTypeFactory().createLinkedType((NativeImg)img));
	final CompositeIntervalView<D, RealComposite<D>> collapsed = Views.collapseReal(img);
	RealComposite<D> extensionCopy = collapsed.randomAccess().get();
	for (int channel = 0; channel < size; ++channel)
		extensionCopy.get(channel).set(valueAtIndex.apply(channel));
	return Views.collapseReal(Converters.convert((RandomAccessibleInterval<D>)img, converter, t.createVariable())).randomAccess().get();
}
 
Example #9
Source File: CollapseRealViewTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void defaultCollapseRealTest() {

	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 },
			new DoubleType());

	CompositeIntervalView<DoubleType, RealComposite<DoubleType>> il2 = Views
			.collapseReal((RandomAccessibleInterval<DoubleType>) img);
	CompositeIntervalView<DoubleType, RealComposite<DoubleType>> opr = ops.transform()
			.collapseRealView((RandomAccessibleInterval<DoubleType>) img);

	assertEquals(il2.numDimensions(), opr.numDimensions());

	CompositeView<DoubleType, RealComposite<DoubleType>> il2_2 = Views
			.collapseReal((RandomAccessible<DoubleType>) img, 1);
	CompositeView<DoubleType, RealComposite<DoubleType>> opr_2 = ops.transform()
			.collapseRealView((RandomAccessible<DoubleType>) img, 1);

	assertEquals(il2_2.numDimensions(), opr_2.numDimensions());
}
 
Example #10
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
final static protected < S extends RealType< S >, T extends RealType< T > > void mapCrop(
		final IterableInterval< S > image,
		final IterableInterval< RealComposite< T > > coefficients )
{
	final Cursor< S > cs = image.cursor();
	final Cursor< RealComposite< T > > ct = coefficients.cursor();
	final S firstValue = cs.next();
	final double minS = firstValue.getMinValue();
	final double maxS = firstValue.getMaxValue();

	while ( cs.hasNext() )
	{
		final S s = cs.next();
		final RealComposite< T > t = ct.next();

		s.setReal( Math.max( minS, Math.min( maxS, s.getRealDouble() * t.get( 0 ).getRealDouble() + t.get( 1 ).getRealDouble() ) ) );
	}
}
 
Example #11
Source File: HessianRAI.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
	List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
	for (int i = 0; i < derivativeComputers.length; i++) {
		RandomAccessibleInterval<T> derivative = createRAI.calculate(input);
		derivativeComputers[i].compute(input, derivative);
		for (int j = 0; j < derivativeComputers.length; j++) {
			RandomAccessibleInterval<T> out = createRAI.calculate(input);
			derivativeComputers[j].compute(derivative, out);
			derivatives.add(out);
		}
	}
	RandomAccessibleInterval<T> stackedDerivatives = Views.stack(derivatives);
	return Views.collapseReal(stackedDerivatives);
}
 
Example #12
Source File: PartialDerivativesRAI.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
	List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
	for (int i = 0; i < derivativeFunctions.length; i++) {
		RandomAccessibleInterval<T> derivative = derivativeFunctions[i].calculate(input);
		derivatives.add(derivative);
	}

	RandomAccessibleInterval<T> stacked = Views.stack(derivatives);
	return Views.collapseReal(stacked);
}
 
Example #13
Source File: FilterNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Executes the "partial derivative" operation on all dimensions */
@OpMethod(op = net.imagej.ops.filter.derivative.PartialDerivativesRAI.class)
public <T extends RealType<T>> CompositeIntervalView<T, RealComposite<T>>
	allPartialDerivatives(final RandomAccessibleInterval<T> in)
{
	@SuppressWarnings("unchecked")
	final CompositeIntervalView<T, RealComposite<T>> result =
		(CompositeIntervalView<T, RealComposite<T>>) ops().run(
			net.imagej.ops.filter.derivative.PartialDerivativesRAI.class, in);
	return result;
}
 
Example #14
Source File: FilterNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.filter.hessian.HessianRAI.class)
public <T extends RealType<T>> CompositeIntervalView<T, RealComposite<T>>
	hessian(final RandomAccessibleInterval<T> in)
{
	@SuppressWarnings("unchecked")
	final CompositeIntervalView<T, RealComposite<T>> result =
		(CompositeIntervalView<T, RealComposite<T>>) ops().run(
			net.imagej.ops.filter.hessian.HessianRAI.class, in);
	return result;
}
 
Example #15
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
final static private < T extends RealType< T > >InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory( final Interpolation interpolation )
{
	switch ( interpolation )
	{
	case NN:
		return new NearestNeighborInterpolatorFactory< RealComposite< T > >();
	default:
		return new NLinearInterpolatorFactory< RealComposite< T > >();
	}
}
 
Example #16
Source File: AffineWarpField.java    From render with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a field with the specified dimensions.
 * Each affine is initialized with identity values.
 *
 * @param  width                pixel width of the warp field.
 * @param  height               pixel height of the warp field.
 * @param  rowCount             number of affine rows in the warp field.
 * @param  columnCount          number of affine columns in the warp field.
 * @param  interpolatorFactory  factory for desired interpolator instance.
 */
public AffineWarpField(final double width,
                       final double height,
                       final int rowCount,
                       final int columnCount,
                       final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> interpolatorFactory)
        throws IllegalArgumentException {
    this(width, height, rowCount, columnCount,
         getDefaultValues(rowCount, columnCount),
         interpolatorFactory);
}
 
Example #17
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public LinearIntensityMap( final RandomAccessibleInterval< T > source, final InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory )
{
	this.interpolatorFactory = interpolatorFactory;
	final CompositeIntervalView< T, RealComposite< T > > collapsedSource = Views.collapseReal( source );
	dimensions = new FinalInterval( collapsedSource );
	final double[] shift = new double[ dimensions.numDimensions() ];
	for ( int d = 0; d < shift.length; ++d )
		shift[ d ] = 0.5;
	translation = new Translation( shift );

	final RandomAccessible< RealComposite< T > > extendedCollapsedSource = Views.extendBorder( collapsedSource );
	coefficients = Views.interpolate( extendedCollapsedSource, interpolatorFactory );
}
 
Example #18
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
final static protected < S extends RealType< S >, T extends RealType< T > > void map(
		final IterableInterval< S > image,
		final IterableInterval< RealComposite< T > > coefficients )
{
	final Cursor< S > cs = image.cursor();
	final Cursor< RealComposite< T > > ct = coefficients.cursor();

	while ( cs.hasNext() )
	{
		final S s = cs.next();
		final RealComposite< T > t = ct.next();
		s.setReal( s.getRealDouble() * t.get( 0 ).getRealDouble() + t.get( 1 ).getRealDouble() );
	}
}
 
Example #19
Source File: AffineWarpFieldTransform.java    From render with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the (potentially interpolated) affine transform for the specified location.
 */
public AffineModel2D getAffine(final double[] location) {

    final double[] warpFieldLocation = { location[0] - locationOffsets[0], location[1] - locationOffsets[1] };

    warpFieldAccessor.setPosition(warpFieldLocation);
    final RealComposite<DoubleType> coefficients = warpFieldAccessor.get();

    final AffineModel2D model = new AffineModel2D();
    model.set(coefficients.get(0).getRealDouble(), coefficients.get(1).getRealDouble(),
              coefficients.get(2).getRealDouble(), coefficients.get(3).getRealDouble(),
              coefficients.get(4).getRealDouble(), coefficients.get(5).getRealDouble());

    return model;
}
 
Example #20
Source File: ConsensusWarpFieldBuilder.java    From render with GNU General Public License v2.0 5 votes vote down vote up
public static double[] getAffineMatrixElements(final RealRandomAccess<RealComposite<DoubleType>> warpFieldAccessor,
                                               final double[] location) {
    warpFieldAccessor.setPosition(location);
    final RealComposite<DoubleType> coefficients = warpFieldAccessor.get();
    return new double[] {
            coefficients.get(0).getRealDouble(),
            coefficients.get(1).getRealDouble(),
            coefficients.get(2).getRealDouble(),
            coefficients.get(3).getRealDouble(),
            coefficients.get(4).getRealDouble(),
            coefficients.get(5).getRealDouble()
    };
}
 
Example #21
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
final static protected < T extends RealType< T > > void mapARGB(
		final IterableInterval< ARGBType > image,
		final IterableInterval< RealComposite< T > > coefficients )
{
	final Cursor< ARGBType > cs = image.cursor();
	final Cursor< RealComposite< T > > ct = coefficients.cursor();

	while ( cs.hasNext() )
	{
		final RealComposite< T > t = ct.next();
		final double alpha = t.get( 0 ).getRealDouble();
		final double beta = t.get( 1 ).getRealDouble();

		final ARGBType s = cs.next();
		final int argb = s.get();
		final int a = ( ( argb >> 24 ) & 0xff );
		final double r = ( ( argb >> 16 ) & 0xff ) * alpha + beta;
		final double g = ( ( argb >> 8 ) & 0xff ) * alpha + beta;
		final double b = ( argb & 0xff ) * alpha + beta;

		s.set(
				( a << 24 ) |
				( ( r < 0 ? 0 : r > 255 ? 255 : ( int )( r + 0.5 ) ) << 16 ) |
				( ( g < 0 ? 0 : g > 255 ? 255 : ( int )( g + 0.5 ) ) << 8 ) |
				( b < 0 ? 0 : b > 255 ? 255 : ( int )( b + 0.5 ) ) );
	}
}
 
Example #22
Source File: GenericBackendDialogN5.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public <T extends RealType<T> & NativeType<T>, V extends AbstractVolatileRealType<T, V> & NativeType<V>>
List<? extends SourceState<RealComposite<T>, VolatileWithSet<RealComposite<V>>>> getChannels(
		final String name,
		final int[] channelSelection,
		final SharedQueue queue,
		final int priority) throws Exception
{
	final N5Reader                  reader            = n5.get();
	final String                    dataset           = this.dataset.get();
	final N5Meta                    meta              = N5Meta.fromReader(reader, dataset);
	final double[]                  resolution        = asPrimitiveArray(resolution());
	final double[]                  offset            = asPrimitiveArray(offset());
	final AffineTransform3D         transform         = N5Helpers.fromResolutionAndOffset(resolution, offset);
	final long                      numChannels       = datasetAttributes.get().getDimensions()[3];

	LOG.debug("Got channel info: num channels={} channels selection={}", numChannels, channelSelection);
	final N5BackendChannel<T, V> backend = new N5BackendChannel<>(n5.get(), dataset, channelSelection, 3);
	final ConnectomicsChannelState<T, V, RealComposite<T>, RealComposite<V>, VolatileWithSet<RealComposite<V>>> state = new ConnectomicsChannelState<>(
			backend,
			queue,
			priority,
			name + "-" + Arrays.toString(channelSelection),
			resolution,
			offset);
	state.converter().setMins(i -> min().get());
	state.converter().setMaxs(i -> max().get());
	return Collections.singletonList(state);
}
 
Example #23
Source File: ChannelSourceState.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public ChannelSourceState(
		final ChannelDataSource<RealComposite<D>, V> dataSource,
		final ARGBCompositeColorConverter<T, CT, V> converter,
		final Composite<ARGBType, ARGBType> composite,
		final String name) {
	super(dataSource, converter, composite, name);
}
 
Example #24
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>, T extends RealType<D>> RealComposite<D>  createExtension(
		final D d,
		final long size
)
{
	return createExtension(d, d.createVariable(), new TypeIdentity<>(), size);
}
 
Example #25
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <T extends RealType<T>> RandomAccessible<RealComposite<T>>[] collapseDimension(
		final RandomAccessibleInterval<T>[] rais,
		final int dimension,
		final long[] channels,
		final T extension
)
{
	return Stream.of(rais).map(rai -> collapseDimension(rai, dimension, channels, extension)).toArray(RandomAccessible[]::new);
}
 
Example #26
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>, T extends RealType<T>> RealComposite<T>  createExtension(
		final D d,
		final T t,
		final Converter<D, T> converter,
		final long size
) {
	return createExtension(d, t, converter, size, channel -> d);
}
 
Example #27
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>> RealComposite<D>  copyExtension(
		final RealComposite<D> extension,
		final long size
)
{
	return copyExtension(extension, extension.get(0).createVariable(), new TypeIdentity<>(), size);
}
 
Example #28
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>, T extends RealType<T>> RealComposite<T>  copyExtension(
		final RealComposite<D> extension,
		final T t,
		final Converter<D, T> converter,
		final long size
)
{
	return createExtension(extension.get(0).createVariable(), t, converter, size, extension::get);
}
 
Example #29
Source File: ARGBCompositeColorConverter.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <
		R extends RealType<R>,
		C extends RealComposite<R>,
		V extends Volatile<C>> void convertInverting(
		V input,
		final ARGBType output,
		final int numChannels,
		final DoubleProperty[] min,
		final double[] scaleR,
		final double[] scaleG,
		final double[] scaleB,
		final int A
) {
	double rd = 0.0;
	double gd = 0.0;
	double bd = 0.0;
	final RealComposite<? extends RealType<?>> c = input.get();
	for (int channel = 0; channel < numChannels; ++channel) {
		final double v = c.get(channel).getRealDouble() - min[channel].get();
		rd += scaleR[channel] * v;
		gd += scaleG[channel] * v;
		bd += scaleB[channel] * v;
	}
	final int r0 = (int) (rd + 0.5);
	final int g0 = (int) (gd + 0.5);
	final int b0 = (int) (bd + 0.5);
	final int r = Math.min(255, Math.max(r0, 0));
	final int g = Math.min(255, Math.max(g0, 0));
	final int b = Math.min(255, Math.max(b0, 0));
	output.set(ARGBType.rgba(r, g, b, A));
}
 
Example #30
Source File: DefaultCollapseReal2CompositeView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public CompositeView<T, RealComposite<T>> calculate(RandomAccessible<T> input) {
	return Views.collapseReal(input, numChannels);
}