public class BinnedWindowedExtractor extends Object implements ImageAnalyser<FImage>, WindowedHistogramExtractor
WindowedHistogramExtractor
with the primary
purpose of of producing efficient access to histograms of arbitrary windows
of the image.
This class analyses an image and produces an 2D array of integers with a one-to-one correspondence with the image pixels. Each integer represents the bin of the histogram into which the corresponding pixel would fall.
Modifier and Type | Field and Description |
---|---|
protected int[][] |
binMap |
protected float |
max |
protected float |
min |
protected int |
nbins |
Constructor and Description |
---|
BinnedWindowedExtractor(int nbins)
Construct with the given number of bins.
|
BinnedWindowedExtractor(int nbins,
float min,
float max)
Construct with the given number of bins, and range.
|
Modifier and Type | Method and Description |
---|---|
void |
analyseImage(FImage image)
Computes the bin-map for this image.
|
Histogram |
computeHistogram(int x,
int y,
FImage weights,
FImage windowWeights)
Compute the histogram for the given window.
|
Histogram |
computeHistogram(int x,
int y,
int w,
int h)
Compute the histogram for the given window.
|
Histogram |
computeHistogram(int x,
int y,
int w,
int h,
FImage weights)
Compute the histogram for the given window.
|
void |
computeHistogram(int x,
int y,
int w,
int h,
Histogram histogram)
Compute the histogram for the given window, storing the output in the
given
Histogram object, which must have the same length as given
by WindowedHistogramExtractor.getNumBins() . |
Histogram |
computeHistogram(Rectangle roi)
Compute the histogram for the given window.
|
Histogram |
computeHistogram(Rectangle roi,
FImage weights)
Compute the histogram for the given window.
|
void |
computeHistogram(Rectangle roi,
Histogram histogram)
Compute the histogram for the given window, storing the output in the
given
Histogram object, which must have the same length as given
by WindowedHistogramExtractor.getNumBins() . |
int[][] |
getBinMap()
Get the bin-map created in the last call to
analyseImage(FImage)
. |
float |
getMax()
Get the expected maximum value in the input image.
|
float |
getMin()
Get the expected minimum value in the input image
|
int |
getNumBins()
Get the number of bins
|
void |
setMax(float max)
Set the expected maximum value.
|
void |
setMin(float min)
Set the expected minimum value.
|
void |
setNbins(int nbins)
Set the number of bins.
|
protected int[][] binMap
protected int nbins
protected float min
protected float max
public BinnedWindowedExtractor(int nbins)
nbins
- number of binspublic BinnedWindowedExtractor(int nbins, float min, float max)
nbins
- number of binsmin
- minimum expected valuemax
- maximum expected valuepublic int getNumBins()
WindowedHistogramExtractor
getNumBins
in interface WindowedHistogramExtractor
public void setNbins(int nbins)
analyseImage(FImage)
is called.nbins
- the number of bins to setpublic float getMin()
public void setMin(float min)
analyseImage(FImage)
is called.min
- the minimum to setpublic float getMax()
public void setMax(float max)
analyseImage(FImage)
is called.max
- the maximum to setpublic void analyseImage(FImage image)
analyseImage
in interface ImageAnalyser<FImage>
image
- The image to process in place.public int[][] getBinMap()
analyseImage(FImage)
.public Histogram computeHistogram(Rectangle roi)
WindowedHistogramExtractor
computeHistogram
in interface WindowedHistogramExtractor
roi
- the windowpublic Histogram computeHistogram(int x, int y, int w, int h)
WindowedHistogramExtractor
computeHistogram
in interface WindowedHistogramExtractor
x
- The x-coordinate of the top-left of the windowy
- The y-coordinate of the top-left of the windoww
- The width of the windowh
- The height of the windowpublic Histogram computeHistogram(Rectangle roi, FImage weights)
roi
- the windowweights
- the weights image. Must be the same size as the analysed
image.public Histogram computeHistogram(int x, int y, int w, int h, FImage weights)
x
- The x-coordinate of the top-left of the windowy
- The y-coordinate of the top-left of the windoww
- The width of the windowh
- The height of the windowweights
- the weights image. Must be the same size as the analysed
image.public Histogram computeHistogram(int x, int y, FImage weights, FImage windowWeights)
This method primarily allows you to compute a spatially weighted histogram. For example, the window weights image could be a 2D Gaussian, and thus the histogram would apply more weight on to the centre pixels.
x
- The x-coordinate of the top-left of the windowy
- The y-coordinate of the top-left of the windowweights
- The weights image. Must be the same size as the analysed
image.windowWeights
- The weights for each pixel in the window.public void computeHistogram(Rectangle roi, Histogram histogram)
WindowedHistogramExtractor
Histogram
object, which must have the same length as given
by WindowedHistogramExtractor.getNumBins()
.computeHistogram
in interface WindowedHistogramExtractor
roi
- the windowhistogram
- the histogram to write topublic void computeHistogram(int x, int y, int w, int h, Histogram histogram)
WindowedHistogramExtractor
Histogram
object, which must have the same length as given
by WindowedHistogramExtractor.getNumBins()
.computeHistogram
in interface WindowedHistogramExtractor
x
- The x-coordinate of the top-left of the windowy
- The y-coordinate of the top-left of the windoww
- The width of the windowh
- The height of the windowhistogram
- the histogram to write to