< prev index next >
core/JemmyCore/src/org/jemmy/image/pixel/AverageDistanceComparator.java
Print this page
*** 30,54 ****
*
* @author shura
*/
public class AverageDistanceComparator extends ThresholdComparator {
- /**
- *
- * @param threshold
- */
public AverageDistanceComparator(double threshold) {
super(0, Math.sqrt(3));
setThreshold(threshold);
}
- /**
- *
- * @param image1
- * @param image2
- * @return
- */
public boolean compare(Raster image1, Raster image2) {
Dimension size = PixelImageComparator.computeDiffSize(image1, image2);
if (size == null) {
return false;
}
--- 30,44 ----
*** 67,76 ****
--- 57,67 ----
}
public static final Raster.Component[] DISTANCE_COMPONENTS = {
Raster.Component.RED, Raster.Component.BLUE, Raster.Component.GREEN
};
+
static double distance(Raster.Component[] comps1, double[] colors1, Raster.Component[] comps2, double[] colors2) {
double res = 0;
double diff;
for (Raster.Component c : DISTANCE_COMPONENTS) {
diff = colors2[PixelImageComparator.arrayIndexOf(comps2, c)] -
*** 78,90 ****
res += diff * diff;
}
return Math.sqrt(res);
}
- /**
- *
- * @return
- */
public String getID() {
return AverageDistanceComparator.class.getName() + ":" + getThreshold();
}
}
--- 69,77 ----
< prev index next >