Search in sources :

Example 1 with PerPixelCameraModel

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;
}
Also used : CameraModel(uk.ac.sussex.gdsc.smlm.model.camera.CameraModel) PerPixelCameraModel(uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel) CalibrationReader(uk.ac.sussex.gdsc.smlm.data.config.CalibrationReader) PerPixelCameraModel(uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel)

Example 2 with PerPixelCameraModel

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;
}
Also used : CameraModelResource(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelResource) PerPixelCameraModel(uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel) CameraModelSettings(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings)

Example 3 with PerPixelCameraModel

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);
    }
}
Also used : PerPixelCameraModel(uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel)

Aggregations

PerPixelCameraModel (uk.ac.sussex.gdsc.smlm.model.camera.PerPixelCameraModel)3 CameraModelResource (uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelResource)1 CameraModelSettings (uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings)1 CalibrationReader (uk.ac.sussex.gdsc.smlm.data.config.CalibrationReader)1 CameraModel (uk.ac.sussex.gdsc.smlm.model.camera.CameraModel)1