Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nfeybesse committed Jun 19, 2018
1 parent 33382bc commit af9aae5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Expand Up @@ -55,10 +55,10 @@ public Img dewarp(Mat frame, Mat binarized, double vRecover, double hRecover) {
List<Mat> hHoughs = hStrips.stream().map(strip -> FHT.fastHoughTransform(strip)).collect(Collectors.toList());
vHoughs.forEach(projectionMap -> Core.normalize(projectionMap, projectionMap, 0, 1, Core.NORM_MINMAX));
hHoughs.forEach(projectionMap -> Core.normalize(projectionMap, projectionMap, 0, 1, Core.NORM_MINMAX));
List<List<TrajectStep>> vHoughTrajs = vHoughs.stream().map(projectionMap -> FHT.bestTrajectFHT(projectionMap, vBlurSize.getValue(), getvAnglePenality().getValue())).collect(Collectors.toList());
List<List<TrajectStep>> hHoughTrajs = hHoughs.stream().map(projectionMap -> FHT.bestTrajectFHT(projectionMap, hBlurSize.getValue(), gethAnglePenality().getValue())).collect(Collectors.toList());
// vHoughTrajs = StripTractor.optimize(vHoughs, 21, -0.08, vNeighbourPenality.get(), vHoughTrajs, vStep);
// hHoughTrajs = StripTractor.optimize(hHoughs, 21, -0.08, hNeighbourPenality.get(), hHoughTrajs, hStep);
List<List<TrajectStep>> vHoughTrajs = vHoughs.stream().map(projectionMap -> FHT.bestTrajectFHT(projectionMap, vBlurSize.getValue(), vAnglePenality.getValue())).collect(Collectors.toList());
List<List<TrajectStep>> hHoughTrajs = hHoughs.stream().map(projectionMap -> FHT.bestTrajectFHT(projectionMap, hBlurSize.getValue(), hAnglePenality.getValue())).collect(Collectors.toList());
vHoughTrajs = StripTractor.optimize(vHoughs, vBlurSize.getValue(), vAnglePenality.getValue(), vNeighbourPenality.get(), vHoughTrajs, vStep);
hHoughTrajs = StripTractor.optimize(hHoughs, hBlurSize.getValue(), hAnglePenality.getValue(), hNeighbourPenality.get(), hHoughTrajs, hStep);
List<List<OrientedPoint>[]> fhtHorizontals = ProjectionLines.toHorizontalsOrientedPoints(vHoughTrajs, vStep, 0.5, 0.05);
List<List<OrientedPoint>[]> fhtVerticals = ProjectionLines.toVerticalsOrientedPoints(hHoughTrajs, hStep, 0.5, 0.05);
List<List<Segment>>[] horizontalSegments = Segment.connect(fhtHorizontals, vStep, 0.05, false);
Expand Down
Expand Up @@ -128,7 +128,7 @@ private Image[] doWork() {
images[3] = new Img(houghTransform255, false).toJfxImage();
ref = trace("FHT", ref);

Mat adaptive = FHT.adaptivHough(houghTransform255, 11);
Mat adaptive = FHT.adaptivHough(houghTransform255, 200);
Core.normalize(adaptive, adaptive, 0, 255, Core.NORM_MINMAX);
images[4] = new Img(adaptive, false).toJfxImage();
adaptive.release();
Expand Down
Expand Up @@ -54,12 +54,12 @@ public GraphicApp() {
@Override
protected void fillGrid(GridPane mainGrid) {

addIntegerSliderProperty("hBlurSize", fhtManager.gethBlurSize(), 10, 100);
addIntegerSliderProperty("vBlurSize", fhtManager.getvBlurSize(), 10, 100);
addIntegerSliderProperty("hBlurSize", fhtManager.gethBlurSize(), 0, 200);
addIntegerSliderProperty("vBlurSize", fhtManager.getvBlurSize(), 0, 200);
addDoubleSliderProperty("hNeighbourPenality", fhtManager.gethNeighbourPenality(), -5000, 0);
addDoubleSliderProperty("vNeighbourPenality", fhtManager.getvNeighbourPenality(), -5000, 0);
addDoubleSliderProperty("hAnglePenality", fhtManager.gethAnglePenality(), -0.2, 0);
addDoubleSliderProperty("vAnglePenality", fhtManager.getvAnglePenality(), -0.2, 0);
addDoubleSliderProperty("hAnglePenality", fhtManager.gethAnglePenality(), -1, 0);
addDoubleSliderProperty("vAnglePenality", fhtManager.getvAnglePenality(), -1, 0);

double displaySizeReduction = 1.5;
for (int col = 0; col < imageViews.length; col++)
Expand Down
Expand Up @@ -44,7 +44,7 @@ public static List<List<TrajectStep>> optimize(List<Mat> vHoughs, int blurSize,
for (int strip = 0; strip < vHoughTrajs.size(); strip++) {
StripTractor[] prevStripInfluences = strip != 0 ? StripTractor.stripInfluences(vHoughTrajs.get(strip - 1), vStep) : noInfluences(vHoughTrajs.get(strip).size());
StripTractor[] nextStripInfluences = strip != vHoughTrajs.size() - 1 ? StripTractor.stripInfluences(vHoughTrajs.get(strip + 1), vStep) : noInfluences(vHoughTrajs.get(strip).size());
vInfluencedTrajs.add(FHT.bestInfluencedTrajectFHT(vHoughs.get(strip), 21, -0.08, -1000, prevStripInfluences, nextStripInfluences));
vInfluencedTrajs.add(FHT.bestInfluencedTrajectFHT(vHoughs.get(strip), blurSize, anglePenality, neigbourPenality, prevStripInfluences, nextStripInfluences));
}
return vInfluencedTrajs;
}
Expand Down

0 comments on commit af9aae5

Please sign in to comment.