Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug fix: Complex.java

  • Loading branch information...
commit 5c3c99610f320ffb8a383bfbe30c4501af8f3f67 1 parent 396606b
@brilliun authored
View
31 src/gui/SrcImgPanel.java
@@ -221,7 +221,7 @@ else if(e.getKeyChar() == 'z'){ // estimate the orientation by four pairs of pat
System.out.println("Zhankai");
if(centerPicked){
- estimateGridEnergy(GRID_GAP);
+ estimateGrid(GRID_GAP);
}
@@ -340,50 +340,48 @@ private void estimateByCenterCross(){
}
- private void estimateGridEnergy(int gridGap){
+ private void estimateGrid(int gridGap){
int centerX = centerCoord.getX();
int centerY = centerCoord.getY();
- double slantAll = 0;
- double tiltAll = 0;
-
+
LinkedList<Orientation> resultList = new LinkedList<Orientation>();
System.out.println("#1");
- resultList.add(estimateSingleEnergy(centerX, centerY)); //#1
+ resultList.add(estimateSingle(centerX, centerY)); //#1
this.repaint();
System.out.println("#2");
- resultList.add(estimateSingleEnergy(centerX - gridGap, centerY)); //#2
+ resultList.add(estimateSingle(centerX - gridGap, centerY)); //#2
this.repaint();
System.out.println("#3");
- resultList.add(estimateSingleEnergy(centerX + gridGap, centerY)); //#3
+ resultList.add(estimateSingle(centerX + gridGap, centerY)); //#3
this.repaint();
System.out.println("#4");
- resultList.add(estimateSingleEnergy(centerX, centerY - gridGap)); //#4
+ resultList.add(estimateSingle(centerX, centerY - gridGap)); //#4
this.repaint();
System.out.println("#5");
- resultList.add(estimateSingleEnergy(centerX, centerY + gridGap)); //#5
+ resultList.add(estimateSingle(centerX, centerY + gridGap)); //#5
this.repaint();
System.out.println("#6");
- resultList.add(estimateSingleEnergy(centerX - gridGap, centerY - gridGap)); //#6
+ resultList.add(estimateSingle(centerX - gridGap, centerY - gridGap)); //#6
this.repaint();
System.out.println("#7");
- resultList.add(estimateSingleEnergy(centerX + gridGap, centerY - gridGap)); //#7
+ resultList.add(estimateSingle(centerX + gridGap, centerY - gridGap)); //#7
this.repaint();
System.out.println("#8");
- resultList.add(estimateSingleEnergy(centerX - gridGap, centerY + gridGap)); //#8
+ resultList.add(estimateSingle(centerX - gridGap, centerY + gridGap)); //#8
this.repaint();
System.out.println("#9");
- resultList.add(estimateSingleEnergy(centerX + gridGap, centerY + gridGap)); //#9
+ resultList.add(estimateSingle(centerX + gridGap, centerY + gridGap)); //#9
this.repaint();
@@ -396,7 +394,7 @@ private void estimateGridEnergy(int gridGap){
}
- private void estimateSingle(int centerX, int centerY){
+ private Orientation estimateSingle(int centerX, int centerY){
LinkedList<Orientation> resultOrientationList = new LinkedList<Orientation>();
@@ -460,10 +458,11 @@ private void estimateSingle(int centerX, int centerY){
estimatedOrientations.add(avgOrient);
- estimatedPositions.add(centerCoord);
+ estimatedPositions.add(new Coordinate2D(centerX, centerY));
needleColor.add(Color.GREEN);
+ return avgOrient;
}
View
4 src/mathUtil/Complex.java
@@ -44,11 +44,11 @@ public void setIm(double imaginary){
public double getAmplitude(){
- return Math.sqrt(this.real * this.real + this.imaginary + this.imaginary);
+ return Math.sqrt(this.real * this.real + this.imaginary * this.imaginary);
}
public double getPower(){
- return this.real * this.real + this.imaginary + this.imaginary;
+ return this.real * this.real + this.imaginary * this.imaginary;
}
public Complex getConjugate() {
View
38 src/sft/ShapeEstimation.java
@@ -30,37 +30,25 @@ public Orientation estimateShape(double[] responseA, double[] responseB, Coordin
double tiltGapD = 1.0;
- double minDiff = 0.0;
+ double minDiff = Double.MAX_VALUE;
double slantD = 0.0;
double tiltD = 0.0;
- DistortionMatrix phi = new DistortionMatrix(viewAngleD, dimension, toRadians(slantD), toRadians(tiltD), pointA, pointB);
-
-
- double responseDiff = ResponseDiff.computeResponseDiff(phi, responseA, responseB);
-
-
-// slantEstimatedD = slantD;
-// tiltEstimatedD = tiltD;
-
- minDiff = responseDiff;
-
-
- for(slantD = slantGapD; slantD < 90.0; slantD += slantGapD)
+ for(slantD = 0.0; slantD < 90.0; slantD += slantGapD){
- for(tiltD = tiltGapD; tiltD < 360.0; tiltD += tiltGapD){
+ for(tiltD = 0.0; tiltD < 360.0; tiltD += tiltGapD){
- phi = new DistortionMatrix(viewAngleD, dimension, toRadians(slantD), toRadians(tiltD), pointA, pointB);
+ DistortionMatrix phi = new DistortionMatrix(viewAngleD, dimension, toRadians(slantD), toRadians(tiltD), pointA, pointB);
- responseDiff = ResponseDiff.computeResponseDiff(phi, responseA, responseB);
+ double responseDiff = ResponseDiff.computeResponseDiff(phi, responseA, responseB);
if(responseDiff < minDiff){
@@ -73,9 +61,21 @@ public Orientation estimateShape(double[] responseA, double[] responseB, Coordin
}
}
-
-
+ }
+
+
+
+ double slantTruthD = 30;
+ double tiltTruthD = 250;
+
+
+ DistortionMatrix phi = new DistortionMatrix(viewAngleD, dimension, toRadians(slantTruthD), toRadians(tiltTruthD), pointA, pointB);
+
+
+ double responseDiffTruth = ResponseDiff.computeResponseDiff(phi, responseA, responseB);
+ System.out.println("EstimatedDiff=" + minDiff);
+ System.out.println("TruthDiff=" + responseDiffTruth);
return Orientation.orientationInDegree(slantEstimatedD, tiltEstimatedD);
Please sign in to comment.
Something went wrong with that request. Please try again.