use of uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel in project GDSC-SMLM by aherbert.
the class PeakFit method checkCameraModel.
/**
* Check the camera model covers the region of the source.
*
* @param fitConfig the fit config
* @param sourceBounds the source bounds of the input image
* @param cropBounds the crop bounds (relative to the input image)
* @param initialise the initialise flag
* @return true, if successful
* @throws IllegalStateException if no camera model exists for the camera type
*/
private static boolean checkCameraModel(FitConfiguration fitConfig, Rectangle sourceBounds, Rectangle cropBounds, boolean initialise) {
final CalibrationReader calibration = fitConfig.getCalibrationReader();
if (calibration.isScmos() && sourceBounds != null) {
CameraModel cameraModel = fitConfig.getCameraModel();
// The camera model origin must be reset to be relative to the source bounds origin
cameraModel = cropCameraModel(cameraModel, sourceBounds, cropBounds, true);
if (cameraModel == null) {
return false;
}
if (initialise && cameraModel instanceof PerPixelCameraModel) {
((PerPixelCameraModel) cameraModel).initialise();
}
fitConfig.setCameraModel(cameraModel);
}
return true;
}
use of uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel in project GDSC-SMLM by aherbert.
the class CameraModelManager method load.
/**
* Load the camera model. Returns null if the named model does not exist. Writes to the ImageJ log
* if a problems occurred loading the model.
*
* @param name the name
* @return the per pixel camera model (or null)
*/
public static PerPixelCameraModel load(String name) {
PerPixelCameraModel model = cameraModels.get(name);
if (model == null) {
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
// Try and get the named resource
final CameraModelResource resource = settings.getCameraModelResourcesMap().get(name);
if (resource == null) {
return null;
}
model = loadFromFile(name, resource.getFilename());
// Cache this
cameraModels.put(name, model);
}
return model;
}
use of uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel in project GDSC-SMLM by aherbert.
the class CameraModelManager method loadFromFileAndSaveResource.
private static void loadFromFileAndSaveResource(String filename) {
final String name = getName(filename);
final PerPixelCameraModel model = loadFromFile(name, filename);
if (model != null) {
saveResource(model, filename, name);
ImageJUtils.log("Load camera model %s data from file: %s", name, filename);
}
}
Aggregations