Search in sources :

Example 96 with ByteProcessor

use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.

the class KMeansClusteringQuantizer method main.

// ----------------------------------------------------------------------
public static void main(String[] args) {
    // String path = "D:/svn-book/Book/img/ch-color-images/alps-01s.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
    String path = "C:/_SVN/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
    // String path = "D:/svn-book/Book/img/ch-color-images/single-color.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/two-colors.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/random-colors.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/ramp-fire.png";
    int K = 16;
    System.out.println("image = " + path);
    System.out.println("K = " + K);
    ImagePlus im = IJ.openImage(path);
    if (im == null) {
        System.out.println("could not open: " + path);
        return;
    }
    ImageProcessor ip = im.getProcessor();
    ColorProcessor cp = ip.convertToColorProcessor();
    Parameters params = new Parameters();
    params.maxColors = K;
    ColorQuantizer quantizer = new KMeansClusteringQuantizer(cp, params);
    quantizer.listColorMap();
    System.out.println("quantizing image");
    ByteProcessor qi = quantizer.quantize(cp);
    System.out.println("showing image");
    (new ImagePlus("quantizez", qi)).show();
}
Also used : ByteProcessor(ij.process.ByteProcessor) ImageProcessor(ij.process.ImageProcessor) ColorProcessor(ij.process.ColorProcessor) ImagePlus(ij.ImagePlus)

Example 97 with ByteProcessor

use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.

the class MedianCutQuantizer method main.

// ----------------------------------------------------------------------
public static void main(String[] args) {
    // String path = "D:/svn-book/Book/img/ch-color-images/alps-01s.png";
    String path = "D:/svn-book/Book/img/ch-color-images/desaturation-hsv/balls.jpg";
    // String path = "D:/svn-book/Book/img/ch-color-images/single-color.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/two-colors.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/random-colors.png";
    // String path = "D:/svn-book/Book/img/ch-color-images/ramp-fire.png";
    int K = 16;
    System.out.println("image = " + path);
    System.out.println("K = " + K);
    ImagePlus im = IJ.openImage(path);
    if (im == null) {
        System.out.println("could not open: " + path);
        return;
    }
    ImageProcessor ip = im.getProcessor();
    ColorProcessor cp = ip.convertToColorProcessor();
    MedianCutQuantizer quantizer = new MedianCutQuantizer(cp, K);
    quantizer.listColorMap();
    System.out.println("quantizing image");
    ByteProcessor qi = quantizer.quantize(cp);
    System.out.println("showing image");
    (new ImagePlus("quantizez", qi)).show();
}
Also used : ByteProcessor(ij.process.ByteProcessor) ImageProcessor(ij.process.ImageProcessor) ColorProcessor(ij.process.ColorProcessor) ImagePlus(ij.ImagePlus)

Example 98 with ByteProcessor

use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.

the class Dft2d method makePowerImage.

public ByteProcessor makePowerImage() {
    ByteProcessor ip = new ByteProcessor(width, height);
    byte[] pixels = (byte[]) ip.getPixels();
    // PowerMax must be set
    double max = Math.log(PowerMax + 1.0);
    double scale = 1.0;
    if (scaleValue > 0)
        scale = scaleValue / max;
    for (int i = 0; i < pixels.length; i++) {
        double p = Power[i];
        if (p < 0)
            p = -p;
        double plog = Math.log(p + 1.0);
        int pint = (int) (plog * scale);
        pixels[i] = (byte) (0xFF & pint);
    }
    if (swapQu)
        swapQuadrants(ip);
    return ip;
}
Also used : ByteProcessor(ij.process.ByteProcessor)

Example 99 with ByteProcessor

use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.

the class IjUtilsTest method testByteArrayReadWrite.

@Test
public void testByteArrayReadWrite() {
    ByteProcessor bp1 = makeRandomByteProcessor(W, H);
    byte[][] A = IjUtils.toByteArray(bp1);
    ByteProcessor bp2 = IjUtils.toByteProcessor(A);
    assertTrue(ImageTests.match(bp1, bp2));
}
Also used : ByteProcessor(ij.process.ByteProcessor) Test(org.junit.Test)

Example 100 with ByteProcessor

use of ij.process.ByteProcessor in project imagingbook-common by imagingbook.

the class ColorEdgeDetector method getRgbFloatChannel.

FloatProcessor getRgbFloatChannel(ColorProcessor cp, int c) {
    // c = 0,1,2
    int w = cp.getWidth();
    int h = cp.getHeight();
    // numbered from 1,...,3!
    ByteProcessor bp = new ByteProcessor(w, h, cp.getChannel(c + 1));
    return bp.convertToFloatProcessor();
}
Also used : ByteProcessor(ij.process.ByteProcessor)

Aggregations

ByteProcessor (ij.process.ByteProcessor)103 ImagePlus (ij.ImagePlus)36 ImageProcessor (ij.process.ImageProcessor)31 FloatProcessor (ij.process.FloatProcessor)23 ShortProcessor (ij.process.ShortProcessor)21 ColorProcessor (ij.process.ColorProcessor)20 ArrayList (java.util.ArrayList)13 Point (java.awt.Point)12 Rectangle (java.awt.Rectangle)11 Roi (ij.gui.Roi)10 AffineTransform (java.awt.geom.AffineTransform)10 ImageStack (ij.ImageStack)9 Patch (ini.trakem2.display.Patch)9 Calibration (ij.measure.Calibration)8 Pair (mpicbg.trakem2.util.Pair)7 Color (java.awt.Color)6 LUT (ij.process.LUT)5 BufferedImage (java.awt.image.BufferedImage)5 IOException (java.io.IOException)5 CoordinateTransformMesh (mpicbg.models.CoordinateTransformMesh)5