From 8201c974cd5f7af82e7f179f668b7314d58980eb Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Tue, 20 Aug 2024 12:41:18 -0400 Subject: [PATCH] fix matching across labels --- .../pairwise/MatcherPairwiseTools.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/net/preibisch/mvrecon/process/interestpointregistration/pairwise/MatcherPairwiseTools.java b/src/main/java/net/preibisch/mvrecon/process/interestpointregistration/pairwise/MatcherPairwiseTools.java index f6a49265..20999692 100644 --- a/src/main/java/net/preibisch/mvrecon/process/interestpointregistration/pairwise/MatcherPairwiseTools.java +++ b/src/main/java/net/preibisch/mvrecon/process/interestpointregistration/pairwise/MatcherPairwiseTools.java @@ -291,12 +291,24 @@ public static < V, I extends InterestPoint > List< Pair< Pair< V, V >, PairwiseR final Map> mapA = interestpoints.get( pair.getA() ); final Map> mapB = interestpoints.get( pair.getB() ); + final HashMap compared = new HashMap<>(); + for ( final String labelA : mapA.keySet() ) for ( final String labelB : mapB.keySet() ) { if ( !matchAcrossLabels && !labelA.equals( labelB ) ) continue; + if ( compared.containsKey( labelA ) && compared.get( labelA ).equals( labelB ) ) + continue; + + // remember what we already compared + compared.put( labelA, labelB ); + + // for matchAcross also the inverse (A>B means we also did B>A) + if ( matchAcrossLabels && !labelA.equals( labelB ) ) + compared.put( labelB, labelA ); + final List< I > listA, listB; if ( matcher.requiresInterestPointDuplication() )