Skip to content

Commit

Permalink
Use 1D specializations also in ransac reduce filter
Browse files Browse the repository at this point in the history
  • Loading branch information
minnerbe committed Jan 20, 2025
1 parent e4f6d0a commit 325d749
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
/**
*
*/
package org.janelia.render.client.intensityadjust.intensity;

import java.util.ArrayList;
Expand All @@ -33,8 +30,9 @@
import mpicbg.models.IllDefinedDataPointsException;
import mpicbg.models.Model;
import mpicbg.models.NotEnoughDataPointsException;
import mpicbg.models.Point;
import mpicbg.models.PointMatch;
import org.janelia.render.client.newsolver.solvers.intensity.Point1D;
import org.janelia.render.client.newsolver.solvers.intensity.PointMatch1D;

/**
* @author Stephan Saalfeld [email protected]
Expand Down Expand Up @@ -95,25 +93,25 @@ public void filter( final List< PointMatch > candidates, final Collection< Point

final double[] minMax = minMax(inliers);
final double weight = 2.0 / model.getMinNumMatches();
final List<Point> points = evenlySpacedPoints(minMax, model.getMinNumMatches());
final List<Point1D> points = evenlySpacedPoints(minMax, model.getMinNumMatches());
inliers.clear();

for (final Point point : points) {
for (final Point1D point : points) {
point.apply(model);
inliers.add(new PointMatch(point, new Point(point.getW().clone()), weight));
inliers.add(new PointMatch1D(point, new Point1D(point.getW()[0]), weight));
}
}

protected List<Point> evenlySpacedPoints(final double[] interval, final int n) {
protected List<Point1D> evenlySpacedPoints(final double[] interval, final int n) {
if (n == 1)
return List.of(new Point(new double[]{ (interval[0] + interval[1]) / 2 }));
return List.of(new Point1D((interval[0] + interval[1]) / 2));

final double min = interval[0];
final double delta = (interval[1] - interval[0]) / (n-1);
final List<Point> points = new ArrayList<>();
final List<Point1D> points = new ArrayList<>();

for (int k = 0; k < n; k++) {
points.add(new Point(new double[]{ min + k*delta }));
points.add(new Point1D(min + k*delta));
}

return points;
Expand Down

0 comments on commit 325d749

Please sign in to comment.