at.ac.sbg.cosy.soccerbot.recognition
Class HSVSimilarity

java.lang.Object
  extended by at.ac.sbg.cosy.soccerbot.recognition.HSVSimilarity

public class HSVSimilarity
extends java.lang.Object

Library for determining similarity of colors in HSV space Original hsv color similarity concept by Volker Rehrmann, University of Koblenz

Author:
Peter Wild

Field Summary
static int[][] REHRMANN_HUEDISTANCE
          HUEDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany direction up: less saturated direction down: more saturated direction left: darker direction right: brighter
static int[][] REHRMANN_SATDISTANCE
          SATDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany
static int[][] REHRMANN_VALDISTANCE
          VALDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany
static int[][] WILD_HUEDISTANCE
          HUEDISTANCE matrix direction up: less saturated direction down: more saturated direction left: darker direction right: brighter
static int[][] WILD_SATDISTANCE
          SATDISTANCE matrix
static int[][] WILD_VALDISTANCE
          VALDISTANCE matrix
 
Constructor Summary
HSVSimilarity()
           
 
Method Summary
static int average(int hsv1, int hsv2, int hsv3, int hsv4)
          Calculates the average hsv color of four given hsv colors
static boolean isSimilar(int hsv1, int hsv2)
          Checks for similarity between two hsv color values according to a similarity check by Volker Rehrmann, University of Koblenz, Germany isSimilar(hsv1,hsv2) = true gdw.
static boolean isSimilar(int hsv1, int hsv2, int[][] huematrix, int[][] satmatrix, int[][] valmatrix)
          Checks for similarity between two hsv color values according to a similarity check by Volker Rehrmann, University of Koblenz, Germany isSimilar(hsv1,hsv2) = true gdw.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WILD_HUEDISTANCE

public static final int[][] WILD_HUEDISTANCE
HUEDISTANCE matrix direction up: less saturated direction down: more saturated direction left: darker direction right: brighter


WILD_SATDISTANCE

public static final int[][] WILD_SATDISTANCE
SATDISTANCE matrix


WILD_VALDISTANCE

public static final int[][] WILD_VALDISTANCE
VALDISTANCE matrix


REHRMANN_HUEDISTANCE

public static final int[][] REHRMANN_HUEDISTANCE
HUEDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany direction up: less saturated direction down: more saturated direction left: darker direction right: brighter


REHRMANN_SATDISTANCE

public static final int[][] REHRMANN_SATDISTANCE
SATDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany


REHRMANN_VALDISTANCE

public static final int[][] REHRMANN_VALDISTANCE
VALDISTANCE matrix by Volker Rehrmann, University of Koblenz, Germany

Constructor Detail

HSVSimilarity

public HSVSimilarity()
Method Detail

isSimilar

public static boolean isSimilar(int hsv1,
                                int hsv2,
                                int[][] huematrix,
                                int[][] satmatrix,
                                int[][] valmatrix)
Checks for similarity between two hsv color values according to a similarity check by Volker Rehrmann, University of Koblenz, Germany isSimilar(hsv1,hsv2) = true gdw. |h1 - h2| <= hue_thresh |s1 - s2| <= sat_thresh |v1 - v2| <= val_thresh with hue_thresh = huematrix sat_thresh = satmatrix val_thresh = valmatrix where hi = hue value of hsvi in [0,...,360] si = saturation value of hsvi in [0...15] vi = value value of hsvi in [0...15]

Parameters:
hsv1 - first hsv value
hsv2 - second hsv value
Returns:
true, if both color values are similar

isSimilar

public static boolean isSimilar(int hsv1,
                                int hsv2)
Checks for similarity between two hsv color values according to a similarity check by Volker Rehrmann, University of Koblenz, Germany isSimilar(hsv1,hsv2) = true gdw. |h1 - h2| <= hue_thresh |s1 - s2| <= sat_thresh |v1 - v2| <= val_thresh with hue_thresh = REHRMANN_HUEDISTANCE[min(s1,s2),max(v1,v2)] sat_thresh = REHRMANN_SATDISTANCE[min(s1,s2),max(v1,v2)] val_thresh = REHRMANN_VALDISTANCE[min(s1,s2),max(v1,v2)] where hi = hue value of hsvi in [0,...,360] si = saturation value of hsvi in [0...15] vi = value value of hsvi in [0...15]

Parameters:
hsv1 - first hsv value
hsv2 - second hsv value
Returns:
true, if both color values are similar

average

public static int average(int hsv1,
                          int hsv2,
                          int hsv3,
                          int hsv4)
Calculates the average hsv color of four given hsv colors

Parameters:
hsv1 - hsv color in 32-bit hsv format (0xHHHHSSVV)
hsv2 - hsv color in 32-bit hsv format (0xHHHHSSVV)
hsv3 - hsv color in 32-bit hsv format (0xHHHHSSVV)
hsv4 - hsv color in 32-bit hsv format (0xHHHHSSVV)
Returns:
average color of hsv1, hsv2, hsv3 and hsv4