Created
December 20, 2016 23:58
-
-
Save zhaar/19f0bf7b7d721a621028c1183fc8b38e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sane signature: Acc -> (Acc, [(Int, Int)]) the list of pair returned contains the index and the amount of votes associated | |
public static Function<HoughAccInterface, Pair<HoughAccInterface, List<Pair<Integer, Integer>>>> mapToClusters(int minVotes, int neighborhood) { | |
return hough -> { | |
//Sane: [(Int, Int)] -> (Int, Int) -> [(Int, Int)] | |
BiFunction<List<Pair<Integer, Integer>>, Pair<Integer, Integer>, List<Pair<Integer, Integer>>> accumulator = (acc, pair) -> { | |
int votes = pair._1(); | |
int index = pair._2(); | |
Pair<Integer, Integer> coord = hough.convertIndex(index); | |
if (votes > minVotes && isLocalMaxima(hough, coord._1(), coord._2(), neighborhood)) { | |
acc.add(new Pair<>(index, votes)); | |
} | |
return acc; | |
}; | |
List<Pair<Integer, Integer>> result = new ArrayList<>(); | |
for (Pair<Integer, Integer> element : MyList.zipWithIndex(hough.getDataArray())) { | |
result = accumulator.apply(result, element); | |
} | |
return new Pair<>(hough, result); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment