17
17
18
18
public class HoughTransformer {
19
19
20
- int centerTolerance , houghTolerance ;
20
+ int centerTolerance ;
21
+ double houghTolerance ;
21
22
22
23
/**
23
24
* The first constructor for HoughTransformer which
24
25
* will set the tolerance for the center of the circle.
25
26
*
26
27
* @param centerTolerance The tolerance in pixels for center of the circle.
27
28
* @param houghTolerance Tolerance for the hough transform (0.0 - 1.0)
29
+ * @param houghConfidence The threshold
30
+ * confidence for determining the type of galaxy.
28
31
*/
29
- public HoughTransformer (int centerTolerance , double houghTolerance ){
32
+ public HoughTransformer (int centerTolerance , double houghTolerance ,
33
+ double houghConfidence ){
30
34
this .centerTolerance = centerTolerance ;
31
35
this .houghTolerance = houghTolerance ;
36
+ this .houghConfidence = houghConfidence ;
32
37
}
33
38
34
39
/**
@@ -39,7 +44,7 @@ public HoughTransformer(int centerTolerance, double houghTolerance){
39
44
* @param img The image to do the processing on.
40
45
* @return boolean Whether or not a circle was found.
41
46
*/
42
- public void process (RenderedImage img ){
47
+ public Category process (RenderedImage img ){
43
48
int width = img .getWidth (), height = img .getHeight ();
44
49
float [] imgData = img .getData ().getPixels (0 ,0 , width ,
45
50
height , (float [])null );
@@ -53,27 +58,29 @@ public void process(RenderedImage img){
53
58
LocatedCircle circle = hough .getLargestCircle (imgData ,
54
59
img .getWidth (), img .getHeight ());
55
60
61
+ System .out .println (circle .getRadius ());
62
+ System .out .println ("Location: (" +circle .getX () +"," +circle .getY ());
63
+ System .out .println ("Confidence: " + circle .getConfidence ());
56
64
/**
57
65
* Check that the circle we're looking for is near the center.
58
66
* If it is not, then the hough transform probably found
59
67
* a larger object than the one in question and failed.
60
68
*/
61
- int circX = circle .getX (), circY = circle .getY ();
62
- if ((circX < width -centerTolerance || circX > width - centerTolerance )
69
+ double circX = circle .getX (), circY = circle .getY ();
70
+ if ((circX < width -centerTolerance || circX > width + centerTolerance )
63
71
|| (circY < height -centerTolerance || circY >height +centerTolerance ))
64
72
return Category .UNDEFINED ;
65
-
66
- System .out .println (circle .getRadius ());
67
- System .out .println ("Location: (" +circle .getX () +"," +circle .getY ());
68
- System .out .println ("Confidence: " + circle .getConfidence ());
73
+
74
+ return Category .UNDEFINED ;
69
75
}
70
76
71
77
72
78
public static void main (String args []){
73
79
if (args .length < 1 )
74
80
System .exit (1 );
75
81
76
- HoughTransformer trans = new HoughTransformer ();
82
+ //The last parameter is a placeholder for now
83
+ HoughTransformer trans = new HoughTransformer (100 , .70 , 100.0 );
77
84
78
85
try {
79
86
trans .process (ImageIO .read (new File (args [0 ])));
0 commit comments