|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.ai.scorer.AbstractScorer
org.hd.d.pg2k.ai.scorer.AbstractImgScorer
org.hd.d.pg2k.ai.scorer.parameterised.LocalSampler
public final class LocalSampler
Simple but configurable Scoring based on local pixel sampling; never null. Since this does not involve any global image operations, running time is nominally independent of image dimensions, ie in all case local image properties are sampled.
This can sample various pixel parameters such as R, G and B components, and can use the absolute values or available ranges.
The set of sample points is a grid spaced in a regular (though not a simple grid) pattern across the image. The layout of the sample points depends on the image size and aspect ratio, and is generated from a pseudo-randon generator, to help avoid poor sampling of images with regular patterns in them,
The confidence depends on the number of selected sample points that are available.
Very small images will have all their pixels sampled, and so can in principle still achieve a MAX confidence.
Parameters include:
This may be most useful for continuous-tone true-colour/greyscale (eg JPEG) images.
| Field Summary | |
|---|---|
private ScorerParamEnum<PixelComponent> |
componentParam
Pixel-value constituent to sample; never null. |
private static ScorerParamEnum<PixelComponent> |
componentParamBounds
Default pixel-value constituent to sample; never null. |
private static ScorerParamInteger |
confidenceMappingParamBoundsBase
Default base confidence mapping output value; never null. |
private java.util.List<ScorerParamInteger> |
confidenceMappingParams
Mapping factors for the score from least to highest input values; never null. |
private static java.util.List<ScorerParamInteger> |
confidenceMappingParamsBounds
Immutable List of default mapping factors for the confidence from least to highest input values; never null. |
private static int |
MAPPING_INTERVALS
Number of intervals in which to map score and confidence; strictly positive. |
private static byte |
MAX_COMPONENT_VALUE
Max brightness returned by samplePoint (minimum is 0); strictly positive. |
private ScorerParamInteger |
outlierParam
Outlier parameter value for this instance; never null. |
private static ScorerParamInteger |
outlierParamBounds
Min, default and max shift for the outlier fraction to remove; never null. |
private ScorerParamEnum<SampleType> |
pixelSampleMethodParam
Pixel sample method; never null. |
private static ScorerParamEnum<SampleType> |
pixelSampleMethodParamBounds
Default pixel sample method; never null. |
private ScorerParamEnum<SampleType> |
sampleCombinationParam
Pixel-value constituent to sample; never null. |
private static ScorerParamEnum<SampleType> |
sampleCombinationParamBounds
Default sample combination method; never null. |
private ScorerParamInteger |
sampleSizeParam
Target sample size for this instance; never null. |
private static ScorerParamInteger |
sampleSizeParamBounds
Min, default and max shift (power-of-two) for the target sample size; never null. |
private static ScorerParamInteger |
scoreMappingParamBoundsBase
Default base score mapping output value; never null. |
private java.util.List<ScorerParamInteger> |
scoreMappingParams
Mapping factors for the score from least to highest input values; never null. |
private static java.util.List<ScorerParamInteger> |
scoreMappingParamsBounds
Immutable List of default mapping factors for the score from least to highest input values; never null. |
| Fields inherited from class org.hd.d.pg2k.ai.scorer.AbstractScorer |
|---|
nameAndParameters, parameterNameRegex, parameterSepRegex, scorerNameRegex, SEPARATOR |
| Constructor Summary | |
|---|---|
LocalSampler()
Create simple non-parameterised instance. |
|
LocalSampler(java.lang.String nameAndParameters)
Create parameterised version. |
|
LocalSampler(java.lang.String baseName,
java.util.List<ScorerParam> parameters)
Create parameterised version. |
|
| Method Summary | |
|---|---|
ScoreAndConf |
computeScoreAndConfidence(java.awt.image.RenderedImage stillImage)
Score the image for "exposure"; never null nor negative in any component. |
ScorerIF |
createVariant(java.lang.String nameAndParameters)
Simple non-static factory for the parameterised case. |
ScorerIF |
createVariant(java.lang.String baseName,
java.util.List<ScorerParam> parameters)
Create variant of same base Scorer with base name and parameters; never null. |
java.util.List<ScorerParam> |
getParameterDefsAndValues()
Get ordered parameter definitions and values (immutable) for this Scorer; never null. |
private static int |
mapRawValue(int rawVal,
java.util.List<ScorerParamInteger> mapping)
Compute (interpolated) mapping from raw value to score/confidence. |
private int |
samplePoint(java.awt.image.BufferedImage stillImage,
int x,
int y)
Take sample at given point in image; null means point cannot be sampled, else [0,127]. |
private int |
samplePointRange(java.awt.image.BufferedImage stillImage,
int x,
int y)
Take sample of area centred on specified point in image; null means point cannot be sampled, else [0,127]. |
private static void |
trimOutliers(int[] sampleCounts,
int nOutliers)
Trim the n outliers of each end of the supplied array of sample counts. |
| Methods inherited from class org.hd.d.pg2k.ai.scorer.AbstractImgScorer |
|---|
computeScoreAndConfidence |
| Methods inherited from class org.hd.d.pg2k.ai.scorer.AbstractScorer |
|---|
canonicalise, createPerturbedVariant, getBaseName, getDefaultName, getNameAndParameters, getPerturbedDefsAndValues, isValidParameterName, isValidScorerName, paramListAsMap, paramListAsString, parseNameAndParameters, similarNParams, verySimilar |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.hd.d.pg2k.ai.scorer.ScorerIF |
|---|
createPerturbedVariant, getBaseName, getNameAndParameters, getPerturbedDefsAndValues |
| Field Detail |
|---|
private static final byte MAX_COMPONENT_VALUE
private static final int MAPPING_INTERVALS
Too small a value hinders a good fit to multi-modal distributions, too large a value makes the state space to explore unnecessarily large.
There is no point in having more intervals than distinct component values (from which this is driven), indeed there should be many fewer.
A power of two may help speed up some computations.
private static final ScorerParamInteger scoreMappingParamBoundsBase
We ensure that this prefix uniquely distinguishes this from all other parameters to give us the maximum possible choice of suffixes.
The perturbation value allows a reasonable state-space exploration speed.
There is no bias: there is no preferred/cheap perturbation direction.
private static final java.util.List<ScorerParamInteger> scoreMappingParamsBounds
private final java.util.List<ScorerParamInteger> scoreMappingParams
private static final ScorerParamInteger confidenceMappingParamBoundsBase
We ensure that this prefix uniquely distinguishes this from all other parameters to give us the maximum possible choice of suffixes.
The perturbation value allows a reasonable state-space exploration speed.
There is no bias: there is no preferred/cheap perturbation direction.
private static final java.util.List<ScorerParamInteger> confidenceMappingParamsBounds
private final java.util.List<ScorerParamInteger> confidenceMappingParams
private static final ScorerParamEnum<SampleType> pixelSampleMethodParamBounds
private final ScorerParamEnum<SampleType> pixelSampleMethodParam
private static final ScorerParamEnum<SampleType> sampleCombinationParamBounds
private final ScorerParamEnum<SampleType> sampleCombinationParam
private static final ScorerParamEnum<PixelComponent> componentParamBounds
private final ScorerParamEnum<PixelComponent> componentParam
private static final ScorerParamInteger sampleSizeParamBounds
private final ScorerParamInteger sampleSizeParam
Reducing the sample size by a factor of x is assumed to increase the noise, and thus reduce the confidence, by a factor of sqrt(x).
Experience suggests that upwards of a thousand samples gives good consistency.
private static final ScorerParamInteger outlierParamBounds
A good shift value may line in the region of 3 to 7 thus discarding ~13% to ~1% of the outliers from either extreme.
private final ScorerParamInteger outlierParam
| Constructor Detail |
|---|
public LocalSampler()
public LocalSampler(java.lang.String nameAndParameters)
public LocalSampler(java.lang.String baseName,
java.util.List<ScorerParam> parameters)
| Method Detail |
|---|
public ScorerIF createVariant(java.lang.String nameAndParameters)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - for unparsable or inappropriate input
public ScorerIF createVariant(java.lang.String baseName,
java.util.List<ScorerParam> parameters)
throws java.lang.IllegalArgumentException
ScorerIFMay be able to share some (immutable) state with the original instance, and the value returned is immutable and may not be new.
java.lang.IllegalArgumentException - for unparsable or inappropriate inputpublic ScoreAndConf computeScoreAndConfidence(java.awt.image.RenderedImage stillImage)
computeScoreAndConfidence in class AbstractImgScorerstillImage - non-null still 2D image;
if greater than 256x256 pixels then will be internally scaled
java.lang.IllegalArgumentException - for a null image
private static void trimOutliers(int[] sampleCounts,
int nOutliers)
sampleCounts - array of non-negative sample count
for each value x at index x; never nullnOutliers - strictly positive outlier count; less than half the total sum
private static final int mapRawValue(int rawVal,
java.util.List<ScorerParamInteger> mapping)
private int samplePointRange(java.awt.image.BufferedImage stillImage,
int x,
int y)
We discard the highest and lowest values (as possible noise) and return the span of the remaining values.
We must be able to find at least 4 (four) samplable values else we must return null.
private int samplePoint(java.awt.image.BufferedImage stillImage,
int x,
int y)
public java.util.List<ScorerParam> getParameterDefsAndValues()
getParameterDefsAndValues in interface ScorerIFgetParameterDefsAndValues in class AbstractScorer
|
DHD Multimedia Gallery V1.50.55 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||