38 * @author KAM
39 */
40 public class NaturalImageComparator extends BufferedImageComparator {
41
42 /**
43 * Creates comparator with the default sensitivity value = 0.02
44 * (around 5 in 0-255 color component value).
45 * @see #NaturalImageComparator(double)
46 */
47 public NaturalImageComparator() {
48 this(0.02);
49 }
50
51 /**
52 * Creates comparator with the specified sensitivity value
53 * @param sensitivity Maximum threshold for 3-D distance between colors
54 * in 3-D sRGB color space for pixels to be considered equal.
55 * Meaningful values are between 0 and approx 1.733. 0 means colors should
56 * be equal to pass the comparison, 1.733 (which is more than square root
57 * of 3) means that comparison will be passed even if the colors are
58 * completely different. You could also use {@linkplain
59 * #findSensitivity(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
60 * findSensitivity()} method to obtain necessary sensitivity value.
61 */
62 public NaturalImageComparator(double sensitivity) {
63 super(new MaxDistanceComparator(sensitivity));
64 }
65 public void setSensitivity(double sensitivity) {
66 ((MaxDistanceComparator)getRasterComparator()).setThreshold(sensitivity);
67 }
68 public double getSensitivity() {
69 return ((MaxDistanceComparator)getRasterComparator()).getThreshold();
70 }
71 }
|
38 * @author KAM
39 */
40 public class NaturalImageComparator extends BufferedImageComparator {
41
42 /**
43 * Creates comparator with the default sensitivity value = 0.02
44 * (around 5 in 0-255 color component value).
45 * @see #NaturalImageComparator(double)
46 */
47 public NaturalImageComparator() {
48 this(0.02);
49 }
50
51 /**
52 * Creates comparator with the specified sensitivity value
53 * @param sensitivity Maximum threshold for 3-D distance between colors
54 * in 3-D sRGB color space for pixels to be considered equal.
55 * Meaningful values are between 0 and approx 1.733. 0 means colors should
56 * be equal to pass the comparison, 1.733 (which is more than square root
57 * of 3) means that comparison will be passed even if the colors are
58 * completely different.
59 */
60 public NaturalImageComparator(double sensitivity) {
61 super(new MaxDistanceComparator(sensitivity));
62 }
63 public void setSensitivity(double sensitivity) {
64 ((MaxDistanceComparator)getRasterComparator()).setThreshold(sensitivity);
65 }
66 public double getSensitivity() {
67 return ((MaxDistanceComparator)getRasterComparator()).getThreshold();
68 }
69 }
|