use of uk.ac.sussex.gdsc.smlm.ij.filters.FhtFilter.Operation in project GDSC-SMLM by aherbert.
the class ImageKernelFilter method setNPasses.
@Override
public void setNPasses(int passes) {
// Create the kernel from the image
boolean build = kernelImp.getID() != lastId || settings.method != lastMethod || settings.filter != lastFilter;
build = build || (settings.method == Settings.METHOD_SPATIAL && kf == null);
build = build || (settings.method == Settings.METHOD_FHT && ff == null);
if (build) {
final Operation operation = Operation.forOrdinal(settings.filter);
FloatProcessor fp = kernelImp.getProcessor().toFloat(0, null);
if (settings.method == Settings.METHOD_SPATIAL) {
if (kf == null || kernelImp.getID() != lastId || settings.zero != lastZero) {
fp = pad(fp);
final int kw = fp.getWidth();
final int kh = fp.getHeight();
final float[] kernel = (float[]) fp.getPixels();
kf = (settings.zero) ? new ZeroKernelFilter(kernel, kw, kh) : new KernelFilter(kernel, kw, kh);
}
switch(operation) {
case CONVOLUTION:
kf.setConvolution(true);
break;
case CORRELATION:
kf.setConvolution(false);
break;
case DECONVOLUTION:
default:
// Spatial filtering does not support anything other than convolution or correlation.
ImageJUtils.log("Unsupported operation (%s), default to correlation", operation.getName());
kf.setConvolution(false);
break;
}
} else {
if (ff == null || kernelImp.getID() != lastId) {
final int kw = fp.getWidth();
final int kh = fp.getHeight();
final float[] kernel = (float[]) fp.getPixels();
ff = new FhtFilter(kernel, kw, kh);
ff.initialiseKernel(dataImp.getWidth(), dataImp.getHeight());
}
ff.setOperation(operation);
}
lastId = kernelImp.getID();
lastMethod = settings.method;
lastFilter = settings.filter;
lastZero = settings.zero;
}
ticker = ImageJUtils.createTicker(passes, passes);
}
Aggregations