|
23 | 23 | package net.preibisch.mvrecon.process.fusion.intensity; |
24 | 24 |
|
25 | 25 | import java.util.ArrayList; |
| 26 | +import java.util.Collection; |
26 | 27 | import java.util.Collections; |
27 | 28 | import java.util.List; |
28 | 29 | import java.util.Map; |
|
37 | 38 | import mpicbg.spim.data.sequence.ViewId; |
38 | 39 | import net.imglib2.iterator.IntervalIterator; |
39 | 40 | import net.preibisch.mvrecon.process.fusion.intensity.IntensityMatcher.CoefficientMatch; |
40 | | -import net.preibisch.mvrecon.process.fusion.intensity.mpicbg.FastAffineModel1D; |
41 | 41 | import net.preibisch.mvrecon.process.fusion.intensity.mpicbg.Point1D; |
42 | 42 | import net.preibisch.mvrecon.process.fusion.intensity.mpicbg.PointMatch1D; |
43 | 43 | import org.slf4j.Logger; |
@@ -70,12 +70,23 @@ public void connect( |
70 | 70 | if (coefficientMatches.isEmpty()) |
71 | 71 | return; |
72 | 72 |
|
| 73 | + final boolean disconnected = coefficientMatches.stream() |
| 74 | + .map(CoefficientMatch::matches) |
| 75 | + .allMatch(Collection::isEmpty); |
| 76 | + |
73 | 77 | final IntensityTile p1IntensityTile = getIntensityTile(p1); |
74 | 78 | final IntensityTile p2IntensityTile = getIntensityTile(p2); |
75 | 79 | for (final CoefficientMatch coefficientMatch : coefficientMatches) { |
76 | 80 | final Tile<?> st1 = p1IntensityTile.getSubTileAtIndex(coefficientMatch.coeff1()); |
77 | 81 | final Tile<?> st2 = p2IntensityTile.getSubTileAtIndex(coefficientMatch.coeff2()); |
78 | | - st1.connect(st2, coefficientMatch.matches()); |
| 82 | + if (disconnected) { |
| 83 | + identityConnect(st1, st2, 1E-6); |
| 84 | + } else { |
| 85 | + final Collection<PointMatch> matches = coefficientMatch.matches(); |
| 86 | + if (!matches.isEmpty()) { |
| 87 | + st1.connect(st2, matches); |
| 88 | + } |
| 89 | + } |
79 | 90 | } |
80 | 91 | p1IntensityTile.connectTo(p2IntensityTile); |
81 | 92 | } |
@@ -177,11 +188,21 @@ private static void equilibrateIntensity(final Tile<?> coefficientTile, |
177 | 188 | coefficientTile.connect(equilibrationTile, Collections.singletonList(eqMatch)); |
178 | 189 | } |
179 | 190 |
|
180 | | - private static void identityConnect(final Tile<?> t1, final Tile<?> t2) { |
| 191 | + // TODO: Here we use (0 -> 0) and (1 -> 1) as point matches that represent |
| 192 | + // the identity transform. This made sense in Render (where this code |
| 193 | + // is copied from), because image intensities are normalized to [0,1]. |
| 194 | + // However, we don't normalize intensities in multiview-reconstruciton, |
| 195 | + // so probably something else should be used here? Dataset min/max? |
| 196 | + // Tile min/max? |
| 197 | + private static void identityConnect(final Tile<?> t1, final Tile<?> t2, final double weight) { |
181 | 198 | final ArrayList<PointMatch> matches = new ArrayList<>(); |
182 | | - matches.add(new PointMatch1D(new Point1D(0), new Point1D(0))); |
183 | | - matches.add(new PointMatch1D(new Point1D(1), new Point1D(1))); |
| 199 | + matches.add(new PointMatch1D(new Point1D(0), new Point1D(0), weight)); |
| 200 | + matches.add(new PointMatch1D(new Point1D(1), new Point1D(1), weight)); |
184 | 201 | t1.connect(t2, matches); |
185 | 202 | } |
186 | 203 |
|
| 204 | + private static void identityConnect(final Tile<?> t1, final Tile<?> t2) { |
| 205 | + identityConnect(t1, t2, 1.0); |
| 206 | + } |
| 207 | + |
187 | 208 | } |
0 commit comments