public class FStatisticalPixelProfileModel extends Object implements PixelProfileModel<FImage>
FStatisticalPixelProfileModel
is a statistical model of pixels
from an FImage
sampled along a line.
The model allows for various sampling strategies (see FLineSampler
)
and uses the mean and covariance as its internal state.
The model is updateable, but does not hold on to previously seen samples to
reduce memory usage.Constructor and Description |
---|
FStatisticalPixelProfileModel(int nsamples,
FLineSampler sampler)
Construct a new
FStatisticalPixelProfileModel with the given
number of samples per line, and the given sampling strategy. |
Modifier and Type | Method and Description |
---|---|
float |
computeCost(FImage image,
Line2d line)
Compute the cost of a vector of samples extracted
along a line in the given image to the internal model.
|
float |
computeMahalanobis(FImage image,
Line2d line)
Compute the Mahalanobis distance of a vector of samples extracted along a
line in the given image to the internal model.
|
float |
computeMahalanobis(float[] vector)
Compute the Mahalanobis distance of the given vector to the internal
model.
|
float[] |
computeMahalanobisWindowed(FImage image,
Line2d line,
int numSamples)
Extract numSamples samples from the line in the image and then compare
this model at each overlapping position starting from the first sample at
the beginning of the line.
|
float[] |
computeMahalanobisWindowed(float[] vector)
Compare this model at each overlapping position of the given vector
starting from the first sample and return the distance for each overlap.
|
float |
computeMovementDistance(FImage image,
Line2d line,
int numSamples,
Point2d pt)
Compute the distance between the centre of the given
line and the given point, normalised as a function of
the length of the sampling line.
|
Point2d |
computeNewBest(FImage image,
Line2d line,
int numSamples)
Extract numSamples samples from the line in the image and
then compare this model at each overlapping position starting
from the first sample at the beginning of the line.
|
Jama.Matrix |
getCovariance() |
Jama.Matrix |
getInverseCovariance() |
double[] |
getMean() |
int |
getNumberSamples() |
FLineSampler |
getSampler() |
String |
toString() |
void |
updateModel(FImage image,
Line2d line)
Update the model with a new sample.
|
public FStatisticalPixelProfileModel(int nsamples, FLineSampler sampler)
FStatisticalPixelProfileModel
with the given
number of samples per line, and the given sampling strategy.nsamples
- number of samplessampler
- line sampling strategypublic void updateModel(FImage image, Line2d line)
PixelProfileModel
updateModel
in interface PixelProfileModel<FImage>
image
- the image to extract the sample fromline
- the line across with to samplepublic double[] getMean()
public Jama.Matrix getCovariance()
public Jama.Matrix getInverseCovariance()
public float computeMahalanobis(float[] vector)
vector
- the vectorpublic float computeMahalanobis(FImage image, Line2d line)
image
- the image to sampleline
- the line to sample alongpublic float[] computeMahalanobisWindowed(FImage image, Line2d line, int numSamples)
image
- the image to sampleline
- the line to sample alongnumSamples
- the number of samples to makepublic Point2d computeNewBest(FImage image, Line2d line, int numSamples)
PixelProfileModel
computeNewBest
in interface PixelProfileModel<FImage>
image
- the image to sampleline
- the line to sample alongnumSamples
- the number of samples to makepublic float computeMovementDistance(FImage image, Line2d line, int numSamples, Point2d pt)
PixelProfileModel
computeMovementDistance
in interface PixelProfileModel<FImage>
image
- the image to sampleline
- the line to sample alongnumSamples
- the number of samples to makept
- the point to comparepublic float[] computeMahalanobisWindowed(float[] vector)
vector
- array of samplespublic int getNumberSamples()
public FLineSampler getSampler()
public float computeCost(FImage image, Line2d line)
PixelProfileModel
computeCost
in interface PixelProfileModel<FImage>
image
- the image to sampleline
- the line to sample along