Search in sources :

Example 21 with FloatArray2D

use of mpi.fruitfly.math.datastructures.FloatArray2D in project TrakEM2 by trakem2.

the class ImageArrayConverter method ImageToFloatArray2D.

public static FloatArray2D ImageToFloatArray2D(ImageProcessor ip) {
    FloatArray2D image;
    Object pixelArray = ip.getPixels();
    int count = 0;
    if (ip instanceof ByteProcessor) {
        image = new FloatArray2D(ip.getWidth(), ip.getHeight());
        byte[] pixels = (byte[]) pixelArray;
        for (int y = 0; y < ip.getHeight(); y++) for (int x = 0; x < ip.getWidth(); x++) image.data[count] = pixels[count++] & 0xff;
    } else if (ip instanceof ShortProcessor) {
        image = new FloatArray2D(ip.getWidth(), ip.getHeight());
        short[] pixels = (short[]) pixelArray;
        for (int y = 0; y < ip.getHeight(); y++) for (int x = 0; x < ip.getWidth(); x++) image.data[count] = pixels[count++] & 0xffff;
    } else if (ip instanceof FloatProcessor) {
        image = new FloatArray2D(ip.getWidth(), ip.getHeight());
        float[] pixels = (float[]) pixelArray;
        for (int y = 0; y < ip.getHeight(); y++) for (int x = 0; x < ip.getWidth(); x++) image.data[count] = pixels[count++];
    } else // RGB
    {
        image = new FloatArray2D(ip.getWidth(), ip.getHeight());
        int[] pixels = (int[]) pixelArray;
    // still unknown how to do...
    /*
            for (int y = 0; y < ip.getHeight(); y++)
                for (int x = 0; x < ip.getWidth(); x++)
                        image[x][y] = pixels[count++];// & 0xffffff;
            */
    }
    return image;
}
Also used : ByteProcessor(ij.process.ByteProcessor) FloatArray2D(mpi.fruitfly.math.datastructures.FloatArray2D) FloatProcessor(ij.process.FloatProcessor) Point(java.awt.Point) ShortProcessor(ij.process.ShortProcessor)

Aggregations

FloatArray2D (mpi.fruitfly.math.datastructures.FloatArray2D)21 Point (java.awt.Point)6 ImageProcessor (ij.process.ImageProcessor)4 ImagePlus (ij.ImagePlus)2 Roi (ij.gui.Roi)2 ByteProcessor (ij.process.ByteProcessor)2 FloatProcessor (ij.process.FloatProcessor)2 ShortProcessor (ij.process.ShortProcessor)2 FloatProcessorT2 (ini.trakem2.imaging.FloatProcessorT2)2 Rectangle (java.awt.Rectangle)2 Random (java.util.Random)2 ImageToFloatArray2D (mpi.fruitfly.general.ImageArrayConverter.ImageToFloatArray2D)2 Patch (ini.trakem2.display.Patch)1 Loader (ini.trakem2.persistence.Loader)1 Image (java.awt.Image)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CrossCorrelation2D (mpi.fruitfly.registration.CrossCorrelation2D)1 PhaseCorrelationPeak (mpicbg.imglib.algorithm.fft.PhaseCorrelationPeak)1 Point (mpicbg.models.Point)1