|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.vision.Histogram
This class provides a simple way of calculating a histogram for a given image.
This class implements Visualizable, for easy viewing and image
output.
TODO: There is still a fair amount to be implemented here, as histograms play
an extremely important part in image analysis, machine vision due to their
statistical importance.
Another possible expansion is to increase the flexibility by allowing a variable
number of bins. HSB support would also be a nice addition.
| Field Summary | |
static int |
BAND_ALL
All the bands |
static int |
BAND_BLUE
The blue band |
static int |
BAND_GREEN
The green band |
static int |
BAND_GREY
The grey band |
static int |
BAND_RED
The red band |
protected java.awt.Color |
clrBackground
The background colour of the visualized histogram |
protected long[][] |
colourBins
The bins for the three colour bands |
protected long[][] |
cumulativeBins
The cumulative histogram bins. |
static int |
DO_LINE
Draw the histogram as a line |
static int |
DO_SOLID
Draw the histograms as a solid shape. |
protected int |
drawOptions
Additional options for drawing. |
protected boolean |
isGreyscale
Is the image greyscale? |
| Constructor Summary | |
Histogram()
Creates a new instance of Histogram |
|
Histogram(java.awt.image.BufferedImage img)
Creates a new instance of Histogram, as well as specifying an image to calculate a histogram for. |
|
Histogram(java.awt.image.BufferedImage img,
int options)
As Histogram(BufferedImage) with additional drawing options. |
|
| Method Summary | |
void |
create(java.awt.image.BufferedImage img)
Create the histogram for a given image. |
protected void |
createCumulative()
Create the cumulative bins. |
long[] |
getCumulativeFrequencies(int b)
Returns the array of cumulative frequencies for the given colour band. |
long |
getCumulativeFrequency(int i)
Return a cumulative frequency at a given index for band 0. |
long |
getCumulativeFrequency(int i,
int b)
Retrieve the cumulative histogram data. |
long[] |
getFrequencies(int b)
Return the frequencies for a given band. |
long |
getFrequency(int i)
Retrieve the frequency for a given band (band 0). |
long |
getFrequency(int i,
int b)
Retrieve the current histogram data. |
long[] |
getMaximum()
Return the maximum values for each band in the histogram. |
double[] |
getMean()
Returns the mean values for each band in the histogram. |
int[] |
getMostFrequent()
This method returns the most frequent bucket for each band in the histogram. |
double[] |
getStandardDeviation()
Returns the standard deviations for each band in the histogram. |
boolean |
isGreyscale()
Has this histogram been created for a greyscale image? |
void |
render(java.awt.Graphics gfx,
int width,
int height)
Renders the histogram as a line or group of solids. |
void |
setBackgroundColour(java.awt.Color bkc)
Set the background colour for the visualized histogram. |
void |
setDrawOptions(int drawOptions)
Set the draw option for the histogram. |
protected void |
writeBand(java.io.File freqFile,
int band)
Write the given histogram band to a FileWriter. |
protected void |
writeCumulativeBand(java.io.File cumFreqFile,
int band)
Write cumulative frequencies for a given colour band. |
void |
writeCumulativeFrequencies(java.io.File freqFile)
Write the cumulative frequencies for a greyscale image. |
void |
writeCumulativeFrequencies(java.io.File redFile,
java.io.File greenFile,
java.io.File blueFile)
Write the cumulative frequencies for an RGB image. |
void |
writeFrequencies(java.io.File freqFile)
Write frequencies for a greyscale histogram. |
void |
writeFrequencies(java.io.File redFile,
java.io.File greenFile,
java.io.File blueFile)
Write frequencies for an RGB image. |
void |
writeImage(java.lang.String filename,
int width,
int height)
Write the visualized histogram to an image file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.awt.Color clrBackground
protected long[][] colourBins
protected long[][] cumulativeBins
protected boolean isGreyscale
protected int drawOptions
DO_SOLID,
DO_LINEpublic static final int BAND_RED
public static final int BAND_GREEN
public static final int BAND_BLUE
public static final int BAND_GREY
public static final int BAND_ALL
public static final int DO_LINE
public static final int DO_SOLID
| Constructor Detail |
public Histogram()
public Histogram(java.awt.image.BufferedImage img)
img - the image to calculate the histogram for.
public Histogram(java.awt.image.BufferedImage img,
int options)
Histogram(BufferedImage) with additional drawing options.
img - the image to calculate the histogram for.options - additional drawing options.Histogram(BufferedImage)| Method Detail |
public void create(java.awt.image.BufferedImage img)
img - the image to calculate the histogram for.protected void createCumulative()
public boolean isGreyscale()
public void setDrawOptions(int drawOptions)
drawOptions - the draw options.public void setBackgroundColour(java.awt.Color bkc)
bkc - the colour (default is Color.lightGray)
public long getFrequency(int i,
int b)
i - the index of the colour bin (0-255).b - the colour band (BAND_RED, BAND_GREEN, BAND_BLUE or BAND_GREY).
public long getFrequency(int i)
return getFrequency(i, 0);
i - the grey level index.
public long[] getFrequencies(int b)
b - the band (red, green or blue).
public long getCumulativeFrequency(int i,
int b)
i - the index of the cumulative bin.b - the colour band.
public long getCumulativeFrequency(int i)
i - the index.
public long[] getCumulativeFrequencies(int b)
b - the colour band.
public long[] getMaximum()
public int[] getMostFrequent()
public double[] getMean()
public double[] getStandardDeviation()
public void render(java.awt.Graphics gfx,
int width,
int height)
render in interface Visualizablegfx - the graphics contextwidth - width of the histogram imageheight - height of the histogram image
public void writeImage(java.lang.String filename,
int width,
int height)
writeImage in interface Visualizablefilename - the filename of the image to write.width - width of the image.height - height of the image.
protected void writeBand(java.io.File freqFile,
int band)
FileWriter.
freqFile - the file writer.band - the band to write.public void writeFrequencies(java.io.File freqFile)
freqFile - the greyscale frequency file.
public void writeFrequencies(java.io.File redFile,
java.io.File greenFile,
java.io.File blueFile)
redFile - the red frequency file.greenFile - the green frequency file.blueFile - the blue frequency file.
protected void writeCumulativeBand(java.io.File cumFreqFile,
int band)
cumFreqFile - the cumulative frequency file.band - the band.public void writeCumulativeFrequencies(java.io.File freqFile)
freqFile - the greyscale cumulative frequency file.
public void writeCumulativeFrequencies(java.io.File redFile,
java.io.File greenFile,
java.io.File blueFile)
redFile - the red cumulative frequency file.greenFile - the green cumulative frequency file.blueFile - the blue cumulative frequency file.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||