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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations