public class MBFStatisticalPixelProfileModel extends Object implements PixelProfileModel<MBFImage>
MBFStatisticalPixelProfileModel
is a statistical model of pixels
from an MBFImage
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.
Internally, the model is one-dimensional, and is created by stacking the
samples from each image band.Constructor and Description |
---|
MBFStatisticalPixelProfileModel(int nsamples,
FLineSampler sampler)
Construct a new
MBFStatisticalPixelProfileModel with the given
number of samples per line, and the given sampling strategy. |
Modifier and Type | Method and Description |
---|---|
float |
computeCost(MBFImage 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(float[] vector)
Compute the Mahalanobis distance of the given vector to the internal
model.
|
float |
computeMahalanobis(MBFImage 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[] |
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[] |
computeMahalanobisWindowed(MBFImage 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 |
computeMovementDistance(MBFImage 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(MBFImage 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(MBFImage image,
Line2d line)
Update the model with a new sample.
|
public MBFStatisticalPixelProfileModel(int nsamples, FLineSampler sampler)
MBFStatisticalPixelProfileModel
with the given
number of samples per line, and the given sampling strategy.nsamples
- number of samplessampler
- line sampling strategypublic void updateModel(MBFImage image, Line2d line)
PixelProfileModel
updateModel
in interface PixelProfileModel<MBFImage>
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(MBFImage image, Line2d line)
image
- the image to sampleline
- the line to sample alongpublic float[] computeMahalanobisWindowed(MBFImage image, Line2d line, int numSamples)
image
- the image to sampleline
- the line to sample alongnumSamples
- the number of samples to makepublic Point2d computeNewBest(MBFImage image, Line2d line, int numSamples)
PixelProfileModel
computeNewBest
in interface PixelProfileModel<MBFImage>
image
- the image to sampleline
- the line to sample alongnumSamples
- the number of samples to makepublic float computeMovementDistance(MBFImage image, Line2d line, int numSamples, Point2d pt)
PixelProfileModel
computeMovementDistance
in interface PixelProfileModel<MBFImage>
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 samples, one vector per bandpublic int getNumberSamples()
public FLineSampler getSampler()
public float computeCost(MBFImage image, Line2d line)
PixelProfileModel
computeCost
in interface PixelProfileModel<MBFImage>
image
- the image to sampleline
- the line to sample along