Class WithResolutionBase<T extends FeatureInputWithResolution>
Object
AnchorBean<Feature<T>>
InitializableBean<Feature<T>,FeatureInitialization>
Feature<T>
FeatureUnary<T,T>
FeatureUnaryGeneric<T>
WithResolutionBase<T>
- Type Parameters:
T
- feature input type, which must include resolution information
- Direct Known Subclasses:
FeatureConvertUnits
,UnitsWithinRange
public abstract class WithResolutionBase<T extends FeatureInputWithResolution>
extends FeatureUnaryGeneric<T>
Base class for a feature that requires input resolution to be calculated.
This class provides a framework for features that depend on image resolution for their calculations. It handles cases where resolution might be missing.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
WithResolutionBase
(Feature<T> feature) Creates a new instance with a specified feature. -
Method Summary
Modifier and TypeMethodDescriptionfinal double
calculate
(FeatureCalculationInput<T> input) Calculates the feature value, handling cases where resolution might be missing.protected abstract double
calculateWithResolution
(double value, Resolution resolution) Calculates the feature value using the provided value and resolution.boolean
Whether to returnDouble.NaN
(if true) or throw an exception (if false) when image resolution is missing.void
setAcceptMissingResolution
(boolean acceptMissingResolution) Whether to returnDouble.NaN
(if true) or throw an exception (if false) when image resolution is missing.Methods inherited from class org.anchoranalysis.feature.bean.operator.FeatureUnary
getItem, inputType, setItem
Methods inherited from class org.anchoranalysis.feature.bean.Feature
assignTo, beforeCalc, calculateCheckInitialized, castAs, createListChildFeatures, describeBean, describeParameters, descriptionLong, duplicateChangeName, getCustomName, getFriendlyName, onInitialization, setCustomName, toString
Methods inherited from class org.anchoranalysis.bean.initializable.InitializableBean
getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise
-
Constructor Details
-
WithResolutionBase
Creates a new instance with a specified feature.- Parameters:
feature
- the feature to be used in calculations
-
WithResolutionBase
public WithResolutionBase()
-
-
Method Details
-
calculate
Calculates the feature value, handling cases where resolution might be missing.- Specified by:
calculate
in classFeature<T extends FeatureInputWithResolution>
- Parameters:
input
- the input for feature calculation- Returns:
- the calculated feature value
- Throws:
FeatureCalculationException
- if an error occurs during calculation
-
calculateWithResolution
protected abstract double calculateWithResolution(double value, Resolution resolution) throws FeatureCalculationException Calculates the feature value using the provided value and resolution.- Parameters:
value
- the input value to be used in the calculationresolution
- the resolution to be used in the calculation- Returns:
- the calculated feature value
- Throws:
FeatureCalculationException
- if an error occurs during calculation
-
isAcceptMissingResolution
public boolean isAcceptMissingResolution()Whether to returnDouble.NaN
(if true) or throw an exception (if false) when image resolution is missing. -
setAcceptMissingResolution
public void setAcceptMissingResolution(boolean acceptMissingResolution) Whether to returnDouble.NaN
(if true) or throw an exception (if false) when image resolution is missing.
-