use of uk.ac.sussex.gdsc.smlm.filters.SingleSpotFilter in project GDSC-SMLM by aherbert.
the class FitEngineConfiguration method createSpotFilter.
/**
* Create the spot filter for identifying candidate maxima. The actual border, search width and
* smoothing parameters can be configured relative to the configured standard deviations or left
* absolute. The standard deviation is used to determine the Half-Width at Half-Maximum (HWHM) for
* each dimension and the parameters set as follows.
*
* <pre>
* int search = (int) Math.ceil(getSearch() * hwhmMax);
* int border = (int) Math.floor(getBorder() * hwhmMax);
* // For each filter
* double smooth = getSmooth(i) * hwhmMin;
* </pre>
*
* @return the maxima spot filter
*/
public MaximaSpotFilter createSpotFilter() {
// Respect the absolute parameter absolute flag for all the distances.
// Get the half-width at half maximum
final double hwhmMin = getHwhmMin();
final double hwhmMax = getHwhmMax();
// Note: rounding to 2 decimal places is a simple method for removing small errors
// in floating point precision from creating an incorrect integer
// Region for maxima finding
int search = (int) Math.ceil(convert(getSearchParameter(), hwhmMax, 2));
if (search < 1) {
search = 1;
}
// Border where peaks are ignored
int border = (int) Math.floor(convert(getBorderParameter(), hwhmMax, 2));
if (border < 0) {
border = 0;
}
final DataProcessor processor0 = createDataProcessor(border, 0, hwhmMin);
final DataFilterSettings f = fitEngineSettings.getDataFilterSettings();
final int filterCount = f.getDataFiltersCount();
final MaximaSpotFilter spotFilter;
if (f.getDataFilterType() == DataFilterType.JURY && filterCount > 1) {
final DataProcessor[] processors = new DataProcessor[filterCount];
processors[0] = processor0;
for (int i = 1; i < filterCount; i++) {
processors[i] = createDataProcessor(border, i, hwhmMin);
}
spotFilter = new JurySpotFilter(search, border, processors);
} else if (f.getDataFilterType() == DataFilterType.DIFFERENCE && filterCount > 1) {
final DataProcessor processor1 = createDataProcessor(border, 1, hwhmMin);
spotFilter = new DifferenceSpotFilter(search, border, processor0, processor1);
} else {
spotFilter = new SingleSpotFilter(search, border, processor0);
}
if (getFitConfiguration().isPerPixelCameraType()) {
if (!spotFilter.isWeighted()) {
throw new IllegalStateException("Camera type requires a weighted spot filter: " + fitConfiguration.getCameraType());
}
final CameraModel model = fitConfiguration.getCameraModel();
if (model == null || !model.isPerPixelModel()) {
throw new IllegalStateException("Weighted spot filter requires a per-pixel camera model");
}
}
return spotFilter;
}
use of uk.ac.sussex.gdsc.smlm.filters.SingleSpotFilter in project GDSC-SMLM by aherbert.
the class SmoothImage method createSpotFilter.
private MaximaSpotFilter createSpotFilter() {
final int search = 1;
final int border = 0;
final DataProcessor processor0 = FitEngineConfiguration.createDataProcessor(border, filters[settings.filter1], settings.smooth1);
if (settings.differenceFilter) {
final DataProcessor processor1 = FitEngineConfiguration.createDataProcessor(border, filters[settings.filter2], settings.smooth2);
return new DifferenceSpotFilter(search, border, processor0, processor1, settings.allowInversion);
}
return new SingleSpotFilter(search, border, processor0);
}
Aggregations