at.tuwien.ifs.somtoolbox.visualization
Class SmoothedDataHistograms

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
      extended by at.tuwien.ifs.somtoolbox.visualization.AbstractMatrixVisualizer
          extended by at.tuwien.ifs.somtoolbox.visualization.SmoothedDataHistograms
All Implemented Interfaces:
BackgroundImageVisualizer, MatrixVisualizer, Comparable<BackgroundImageVisualizer>, EventListener, ChangeListener

public class SmoothedDataHistograms
extends AbstractMatrixVisualizer
implements BackgroundImageVisualizer, ChangeListener

This visualizer provides an implementation of the Smoothed Data Histograms in three variants.

  1. Implementation of the Smoothed Data Histograms as described in E. Pampalk, A. Rauber, and D. Merkl. Proceedings of the International Conference on Artificial Neural Networks (ICANN'02), pp 871-876, LNCS 2415, Madrid, Spain, August 27-30, 2002, Springer Verlag.
  2. An extension of the Smoothed Data Histograms. Not the rank is taken into account for histogram calculation, but distances "between input vectors and weight vectors.
  3. As 2., but additionally values are normalized per datum.

Version:
$Id: SmoothedDataHistograms.java 3888 2010-11-02 17:42:53Z frank $
Author:
Michael Dittenbach, Rudolf Mayer

Nested Class Summary
protected  class SmoothedDataHistograms.Histogram
           
 class SmoothedDataHistograms.SDHControlPanel
          A control panel extending the generic AbstractBackgroundImageVisualizer.VisualizationControlPanel, adding additionally a JSpinner for controlling the smoothing factor.
 
Nested classes/interfaces inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
AbstractBackgroundImageVisualizer.ContourInterpolationMode, AbstractBackgroundImageVisualizer.ContourMode, AbstractBackgroundImageVisualizer.VisualizationControlPanel
 
Field Summary
protected  SOMLibDataWinnerMapping dataWinnerMapping
           
protected static int DEFAULT_SMOOTHING_VALUE
          The default value for the smoothing factor (15).
protected static int MAX_SMOOTHING_VALUE
          The maximum value for the smoothing factor (300).
protected static int MIN_SMOOTHING_VALUE
          The minimum value for the smoothing factor (1), resulting in only the best winning units to get a hit counted.
protected  int s
          The currently used smoothing factor.
protected  Hashtable<Integer,SmoothedDataHistograms.Histogram>[] smoothingCache
          A cache for the different smoothing factors.
 
Fields inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractMatrixVisualizer
maximumMatrixValue, minimumMatrixValue, palette
 
Fields inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
cache, CACHE_KEY_SECTION_SEPARATOR, CACHE_KEY_SEPARATOR, contourInterpolationMode, contourMode, controlPanel, currentZDimSlice, inputObjects, interpolate, log, map, MAX_CACHE_SIZE_MB, neededInputObjects, NUM_VISUALIZATIONS, numberOfContours, opacity, preferredScaleFactor, VISUALIZATION_DESCRIPTIONS, VISUALIZATION_NAMES, VISUALIZATION_SHORT_NAMES, visualizationUpdateListener, zSize
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.visualization.BackgroundImageVisualizer
DEFAULT_BACKGROUND_VISUALIZATION_SCALE
 
Constructor Summary
SmoothedDataHistograms()
           
 
Method Summary
protected  void ceckInitSmoothingCache(GrowingSOM gsom, boolean forceSmoothingCacheInitialisation)
           
protected  void checkNeededObjectsAvailable(GrowingSOM gsom)
           
protected  void computeDefaultAndMaxSmoothingValues(int xSize, int ySize)
           
protected  flanagan.interpolation.BiCubicSplineFast computeSpline(GrowingSOM gsom, cern.colt.matrix.DoubleMatrix2D matrix, int width, int height, int unitWidth, int unitHeight)
           
 BufferedImage createVisualization(int index, GrowingSOM gsom, int width, int height)
          Creates a visualisation image.
 BufferedImage createVisualization(int index, GrowingSOM gsom, int width, int height, int blockWidth, int blockHeight, boolean forceSmoothingCacheInitialisation, boolean shallDrawBackground)
           
protected  String getCacheKey(GrowingSOM gsom, int index, int width, int height)
          The key of a cache is created as follows: VisualisationShortName + Hashcode of the SOM + Width + Height + Opacity.
Sub-classes might add more information to the cache, if needed.
 String getHTMLVisualisationControl(Map params)
          Returns HTML control elements (inputs) to be used by the webserver version of the SOM.
 int getSmoothingFactor()
          Return the currently used smoothing factor.
 BufferedImage getVisualization(int index, int smoothingFactor, GrowingSOM gsom, int width, int height)
          Visualisation for a specific smoothing factor
 HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex, GrowingSOM gsom, int width, int height)
          Default implementation which returns a map of size 1 with the standard, unparameterised visualisation of the given variant.
 HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex, GrowingSOM gsom, int width, int height, int maxFlavours)
          Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).
 HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex, GrowingSOM gsom, int width, int height, Map<String,String> flavourParameters)
          Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).
protected  void initSmoothingCache(GrowingSOM gsom)
           
 String[] needsAdditionalFiles()
          Overrides AbstractBackgroundImageVisualizer.needsAdditionalFiles(), as we need only one of the two possible input files to create this visualisation.
 void setSmoothingFactor(int smoothingFactor)
          Sets the smoothing factor.
 void stateChanged(ChangeEvent e)
           
 
Methods inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractMatrixVisualizer
computeHitHistogram, constrainWithinPalette, createImage, drawContour, getCurrentPalette, getMaximumMatrixValue, getMinimumMatrixValue, getPalette, getPreferredPaletteName, getVisualization, invalidateCache, reversePalette, setInterpolate, setPalette
 
Methods inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
appendToCacheKey, buildCacheKey, checkVariantIndex, clearVisualisationCache, compareTo, createVisualization, drawBackground, getControlPanel, getNumberOfVisualizations, getPreferredScaleFactor, getVariantException, getVisualizationDescription, getVisualizationDescriptions, getVisualizationName, getVisualizationNames, getVisualizationShortName, getVisualizationShortNames, invalidateCache, logImageCache, setInputObjects, setMap, setSOMData, setVisualizationUpdateListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface at.tuwien.ifs.somtoolbox.visualization.BackgroundImageVisualizer
getControlPanel, getNumberOfVisualizations, getPreferredScaleFactor, getVisualization, getVisualizationDescription, getVisualizationDescriptions, getVisualizationName, getVisualizationNames, getVisualizationShortName, getVisualizationShortNames, setInputObjects, setMap, setSOMData, setVisualizationUpdateListener
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

MIN_SMOOTHING_VALUE

protected static final int MIN_SMOOTHING_VALUE
The minimum value for the smoothing factor (1), resulting in only the best winning units to get a hit counted.

See Also:
Constant Field Values

MAX_SMOOTHING_VALUE

protected static int MAX_SMOOTHING_VALUE
The maximum value for the smoothing factor (300).


DEFAULT_SMOOTHING_VALUE

protected static int DEFAULT_SMOOTHING_VALUE
The default value for the smoothing factor (15).


s

protected int s
The currently used smoothing factor. The smoothing factor decides how many n-best matching units get a hit counted.


smoothingCache

protected Hashtable<Integer,SmoothedDataHistograms.Histogram>[] smoothingCache
A cache for the different smoothing factors.


dataWinnerMapping

protected SOMLibDataWinnerMapping dataWinnerMapping
Constructor Detail

SmoothedDataHistograms

public SmoothedDataHistograms()
Method Detail

getCacheKey

protected String getCacheKey(GrowingSOM gsom,
                             int index,
                             int width,
                             int height)
Description copied from class: AbstractBackgroundImageVisualizer
The key of a cache is created as follows: VisualisationShortName + Hashcode of the SOM + Width + Height + Opacity.
Sub-classes might add more information to the cache, if needed.

Overrides:
getCacheKey in class AbstractMatrixVisualizer

getVisualization

public BufferedImage getVisualization(int index,
                                      int smoothingFactor,
                                      GrowingSOM gsom,
                                      int width,
                                      int height)
                               throws SOMToolboxException
Visualisation for a specific smoothing factor

Throws:
SOMToolboxException

createVisualization

public BufferedImage createVisualization(int index,
                                         GrowingSOM gsom,
                                         int width,
                                         int height)
                                  throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Creates a visualisation image. Subclasses must implement this method.

Specified by:
createVisualization in class AbstractBackgroundImageVisualizer
Parameters:
index - the index of the variant to use
gsom - the GrowingSOM to take build the visualisation for
width - the desired width of the image, in pixels
height - the desired height of the image, in pixels.
Returns:
an image for this visualisation.
Throws:
SOMToolboxException

createVisualization

public BufferedImage createVisualization(int index,
                                         GrowingSOM gsom,
                                         int width,
                                         int height,
                                         int blockWidth,
                                         int blockHeight,
                                         boolean forceSmoothingCacheInitialisation,
                                         boolean shallDrawBackground)
                                  throws SOMToolboxException
Throws:
SOMToolboxException

computeSpline

protected flanagan.interpolation.BiCubicSplineFast computeSpline(GrowingSOM gsom,
                                                                 cern.colt.matrix.DoubleMatrix2D matrix,
                                                                 int width,
                                                                 int height,
                                                                 int unitWidth,
                                                                 int unitHeight)
Overrides:
computeSpline in class AbstractMatrixVisualizer

checkNeededObjectsAvailable

protected void checkNeededObjectsAvailable(GrowingSOM gsom)
                                    throws SOMToolboxException
Overrides:
checkNeededObjectsAvailable in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

ceckInitSmoothingCache

protected void ceckInitSmoothingCache(GrowingSOM gsom,
                                      boolean forceSmoothingCacheInitialisation)
                               throws SOMToolboxException
Throws:
SOMToolboxException

stateChanged

public void stateChanged(ChangeEvent e)
Specified by:
stateChanged in interface ChangeListener

getSmoothingFactor

public int getSmoothingFactor()
Return the currently used smoothing factor.

Returns:
the smoothing factor

computeDefaultAndMaxSmoothingValues

protected void computeDefaultAndMaxSmoothingValues(int xSize,
                                                   int ySize)

initSmoothingCache

protected void initSmoothingCache(GrowingSOM gsom)
                           throws SOMToolboxException
Throws:
SOMToolboxException

needsAdditionalFiles

public String[] needsAdditionalFiles()
Overrides AbstractBackgroundImageVisualizer.needsAdditionalFiles(), as we need only one of the two possible input files to create this visualisation. If the data winner mapping is present, it will be used directly, otherwise it can be created from the input vectors.

Specified by:
needsAdditionalFiles in interface BackgroundImageVisualizer
Overrides:
needsAdditionalFiles in class AbstractBackgroundImageVisualizer
Returns:
an array containing the names of the input objects needed

setSmoothingFactor

public void setSmoothingFactor(int smoothingFactor)
Sets the smoothing factor.

Parameters:
smoothingFactor - the new smoothing factor

getHTMLVisualisationControl

public String getHTMLVisualisationControl(Map params)
Description copied from interface: BackgroundImageVisualizer
Returns HTML control elements (inputs) to be used by the webserver version of the SOM. Only the inputs are required, the surrounding form will be provided.

Specified by:
getHTMLVisualisationControl in interface BackgroundImageVisualizer
Overrides:
getHTMLVisualisationControl in class AbstractBackgroundImageVisualizer
Parameters:
params - the parameters as passed by the web request - used to select the values in the inputs.
Returns:
HTML code containing the inputs

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation which returns a map of size 1 with the standard, unparameterised visualisation of the given variant. Subclasses that want to return more flavours should override this method.

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height,
                                                              int maxFlavours)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int variantIndex,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height,
                                                              Map<String,String> flavourParameters)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException