[wosaic commit] r340 - trunk/src/wosaic/algorithms

3 views
Skip to first unread message

codesite...@google.com

unread,
Sep 17, 2008, 5:15:16 PM9/17/08
to wosaic...@googlegroups.com
Author: swegner2
Date: Wed Sep 17 14:12:32 2008
New Revision: 340

Modified:
trunk/src/wosaic/algorithms/AbstractAlgorithm.java

Log:
Use RMS scores for the distance function

Modified: trunk/src/wosaic/algorithms/AbstractAlgorithm.java
==============================================================================
--- trunk/src/wosaic/algorithms/AbstractAlgorithm.java (original)
+++ trunk/src/wosaic/algorithms/AbstractAlgorithm.java Wed Sep 17 14:12:32
2008
@@ -76,6 +76,7 @@
* @return A positive distance "score".
*/
protected int getMatchScore(Pixel pixel, int r, int c) {
+
int[] avgColors = new int[3];
pixel.getAvgImageColor(avgColors);
final int rmDiff = Math.abs(avgColors[0] - ColorMap[r][c][0]);
@@ -86,7 +87,7 @@
// Like in golf, a lower score is better. This is simply
// made up of the total difference in each channel, added
// together. Other weights can be added in the future.
- return rmDiff + gmDiff + bmDiff;
+ return (int) Math.sqrt((Math.pow(rmDiff, 2.0) + Math.pow(gmDiff, 2.0) +
Math.pow(bmDiff, 2.0)));
}

public static final AbstractAlgorithm CreateAlgorithm(Algorithms
algorithm, Mosaic mos, int[][][] colorMap) {

Reply all
Reply to author
Forward
0 new messages