Search in sources :

Example 16 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class PCPALMAnalysis method pad.

/**
	 * Pads the image to the next power of two
	 * 
	 * @param ip
	 * @return padded image
	 */
private FloatProcessor pad(ImageProcessor ip) {
    // Pad to a power of 2
    final int size = FastMath.max(ip.getWidth(), ip.getHeight());
    int newSize = nextPowerOfTwo(size);
    if (size > newSize)
        // Error
        return null;
    FloatProcessor im2 = new FloatProcessor(newSize, newSize);
    // If the binary processor has a min and max this breaks the conversion to float
    // since values are mapped from 0-255 using the min-max look-up calibration table
    ip.resetMinAndMax();
    im2.insert(ip, 0, 0);
    return im2;
}
Also used : FloatProcessor(ij.process.FloatProcessor)

Example 17 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class TraceMolecules method createNNPlot.

private FloatProcessor createNNPlot(List<double[]> results, int w, int h) {
    FloatProcessor fp = new FloatProcessor(w, h);
    // Create lookup table that map the tested threshold values to a position in the image
    int[] xLookup = createLookup(tThresholds, settings.minTimeThreshold, w);
    int[] yLookup = createLookup(dThresholds, settings.minDistanceThreshold, h);
    origX = (settings.minTimeThreshold != 0) ? xLookup[1] : 0;
    origY = (settings.minDistanceThreshold != 0) ? yLookup[1] : 0;
    int gridWidth = tThresholds.length;
    int gridHeight = dThresholds.length;
    for (int y = 0, i = 0; y < gridHeight; y++) {
        for (int x = 0; x < gridWidth; x++, i++) {
            int x1 = xLookup[x];
            int x2 = xLookup[x + 1];
            int y1 = yLookup[y];
            int y2 = yLookup[y + 1];
            double[] result = results.get(i);
            fp.setValue(Math.abs(result[2]));
            fp.setRoi(x1, y1, x2 - x1, y2 - y1);
            fp.fill();
        }
    }
    return fp;
}
Also used : FloatProcessor(ij.process.FloatProcessor) ClusterPoint(gdsc.core.clustering.ClusterPoint)

Example 18 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class PCPALMAnalysis method createWeightImage.

/**
	 * Create a weight image of the same size. All pixels corresponding to the original image area
	 * are set to 1. A window function is optionally applied.
	 * 
	 * @param im
	 * @param applyWindow
	 * @return The weight image
	 */
private ImageProcessor createWeightImage(ImageProcessor im, boolean applyWindow) {
    float[] data = new float[im.getWidth() * im.getHeight()];
    Arrays.fill(data, 1);
    ImageProcessor w = new FloatProcessor(im.getWidth(), im.getHeight(), data, null);
    if (applyWindow) {
        w = applyWindow(w, imageWindow);
    }
    return w;
}
Also used : ImageProcessor(ij.process.ImageProcessor) FloatProcessor(ij.process.FloatProcessor)

Example 19 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class PCPALMAnalysis method computeAutoCorrelationCurveFFT.

/**
	 * Compute the auto-correlation curve using FFT. Computes the correlation image and then samples
	 * the image at radii up to the specified length to get the average correlation at a given
	 * radius.
	 * 
	 * @param im
	 * @param w
	 * @param maxRadius
	 * @param nmPerPixel
	 * @return { distances[], gr[], gr_se[] }
	 */
private double[][] computeAutoCorrelationCurveFFT(ImageProcessor im, ImageProcessor w, int maxRadius, double nmPerPixel, double density) {
    log("Performing FFT correlation");
    FloatProcessor corrIm = computeAutoCorrelationFFT(im);
    FloatProcessor corrW = computeAutoCorrelationFFT(w);
    if (corrIm == null || corrW == null) {
        error("Unable to perform Fourier transform");
        return null;
    }
    final int centre = corrIm.getHeight() / 2;
    Rectangle crop = new Rectangle(centre - maxRadius, centre - maxRadius, maxRadius * 2, maxRadius * 2);
    if (showCorrelationImages) {
        displayCorrelation(corrIm, "Image correlation FFT", crop);
        displayCorrelation(corrW, "Window correlation FFT", crop);
    }
    log("  Normalising correlation");
    FloatProcessor correlation = normaliseCorrelation(corrIm, corrW, density);
    if (showCorrelationImages)
        displayCorrelation(correlation, "Normalised correlation FFT", crop);
    return computeRadialAverage(maxRadius, nmPerPixel, correlation);
}
Also used : FloatProcessor(ij.process.FloatProcessor) Rectangle(java.awt.Rectangle)

Example 20 with FloatProcessor

use of ij.process.FloatProcessor in project GDSC-SMLM by aherbert.

the class PCPALMAnalysis method padToFHT2.

/**
	 * Pads the image to the next power of two and transforms into the frequency domain
	 * 
	 * @param ip
	 * @return An FHT2 image in the frequency domain
	 */
private FHT2 padToFHT2(ImageProcessor ip) {
    FloatProcessor im2 = pad(ip);
    if (im2 == null)
        return null;
    FHT2 FHT2 = new FHT2(im2);
    FHT2.setShowProgress(false);
    FHT2.transform();
    return FHT2;
}
Also used : FHT2(ij.process.FHT2) FloatProcessor(ij.process.FloatProcessor)

Aggregations

FloatProcessor (ij.process.FloatProcessor)49 Test (org.junit.Test)22 ImageProcessor (ij.process.ImageProcessor)11 Rectangle (java.awt.Rectangle)8 FHT2 (ij.process.FHT2)5 ImageStack (ij.ImageStack)4 Point (java.awt.Point)4 LinkedList (java.util.LinkedList)4 Future (java.util.concurrent.Future)4 ClusterPoint (gdsc.core.clustering.ClusterPoint)3 IJImagePeakResults (gdsc.smlm.ij.results.IJImagePeakResults)3 ImagePlus (ij.ImagePlus)3 RandomGenerator (org.apache.commons.math3.random.RandomGenerator)3 Well19937c (org.apache.commons.math3.random.Well19937c)3 BasePoint (gdsc.core.match.BasePoint)2 MaximaSpotFilter (gdsc.smlm.filters.MaximaSpotFilter)2 IJTablePeakResults (gdsc.smlm.ij.results.IJTablePeakResults)2 PeakResult (gdsc.smlm.results.PeakResult)2 ColorProcessor (ij.process.ColorProcessor)2 ShortProcessor (ij.process.ShortProcessor)2