Search in sources :

Example 6 with UnsignedShortType

use of net.imglib2.type.numeric.integer.UnsignedShortType in project TrakEM2 by trakem2.

the class LinearIntensityMap method main.

public static void main(final String[] args) {
    new ImageJ();
    final double[] coefficients = new double[] { 0, 2, 4, 8, 1, 1, 1, 1, 1, 10, 5, 1, 1, 1, 1, 1, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 };
    final LinearIntensityMap<DoubleType> transform = new LinearIntensityMap<DoubleType>(ArrayImgs.doubles(coefficients, 4, 4, 2));
    // final ImagePlus imp = new ImagePlus( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png" );
    final ImagePlus imp1 = new ImagePlus("http://fly.mpi-cbg.de/~saalfeld/Pictures/norway.jpg");
    final ArrayImg<FloatType, FloatArray> image1 = ArrayImgs.floats((float[]) imp1.getProcessor().convertToFloatProcessor().getPixels(), imp1.getWidth(), imp1.getHeight());
    final ArrayImg<UnsignedByteType, ByteArray> image2 = ArrayImgs.unsignedBytes((byte[]) imp1.getProcessor().convertToByteProcessor().getPixels(), imp1.getWidth(), imp1.getHeight());
    final ArrayImg<UnsignedShortType, ShortArray> image3 = ArrayImgs.unsignedShorts((short[]) imp1.getProcessor().convertToShortProcessor().getPixels(), imp1.getWidth(), imp1.getHeight());
    final ArrayImg<ARGBType, IntArray> image4 = ArrayImgs.argbs((int[]) imp1.getProcessor().getPixels(), imp1.getWidth(), imp1.getHeight());
    ImageJFunctions.show(ArrayImgs.doubles(coefficients, 4, 4, 2));
    transform.run(image1);
    transform.run(image2);
    transform.run(image3);
    transform.run(image4);
    ImageJFunctions.show(image1);
    ImageJFunctions.show(image2);
    ImageJFunctions.show(image3);
    ImageJFunctions.show(image4);
}
Also used : UnsignedShortType(net.imglib2.type.numeric.integer.UnsignedShortType) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ImagePlus(ij.ImagePlus) FloatType(net.imglib2.type.numeric.real.FloatType) ImageJ(ij.ImageJ) FloatArray(net.imglib2.img.basictypeaccess.array.FloatArray) IntArray(net.imglib2.img.basictypeaccess.array.IntArray) DoubleType(net.imglib2.type.numeric.real.DoubleType) ByteArray(net.imglib2.img.basictypeaccess.array.ByteArray) ARGBType(net.imglib2.type.numeric.ARGBType) ShortArray(net.imglib2.img.basictypeaccess.array.ShortArray)

Aggregations

UnsignedShortType (net.imglib2.type.numeric.integer.UnsignedShortType)6 BitType (net.imglib2.type.logic.BitType)2 Test (org.junit.Test)2 ImageJ (ij.ImageJ)1 ImagePlus (ij.ImagePlus)1 List (java.util.List)1 Random (java.util.Random)1 CalibratedAxis (net.imagej.axis.CalibratedAxis)1 DefaultLinearAxis (net.imagej.axis.DefaultLinearAxis)1 AbstractOpTest (net.imagej.ops.AbstractOpTest)1 AbstractThresholdTest (net.imagej.ops.threshold.AbstractThresholdTest)1 Interval (net.imglib2.Interval)1 IterableInterval (net.imglib2.IterableInterval)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 ByteArray (net.imglib2.img.basictypeaccess.array.ByteArray)1 FloatArray (net.imglib2.img.basictypeaccess.array.FloatArray)1 IntArray (net.imglib2.img.basictypeaccess.array.IntArray)1 ShortArray (net.imglib2.img.basictypeaccess.array.ShortArray)1 LabelRegion (net.imglib2.roi.labeling.LabelRegion)1 LabelRegionCursor (net.imglib2.roi.labeling.LabelRegionCursor)1