Skip to content

Commit 07bf4d7

Browse files
committed
Made a new constructor for the HoughTransformer
I also made an enum for the different galaxy categories.
1 parent 3ed0da7 commit 07bf4d7

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

Category.java

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* filename: Category.java
3+
*
4+
* @class CategoryEnum This class represents what category
5+
* of galaxy an image is in. It can be one of elliptical,
6+
* spiral, or undefined.
7+
*/
8+
9+
public enum Category {
10+
ELLIPTICAL,SPIRAL,UNDEFINED
11+
}

HoughTransformer.java

+17-10
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,23 @@
1717

1818
public class HoughTransformer{
1919

20-
int centerTolerance, houghTolerance;
20+
int centerTolerance;
21+
double houghTolerance;
2122

2223
/**
2324
* The first constructor for HoughTransformer which
2425
* will set the tolerance for the center of the circle.
2526
*
2627
* @param centerTolerance The tolerance in pixels for center of the circle.
2728
* @param houghTolerance Tolerance for the hough transform (0.0 - 1.0)
29+
* @param houghConfidence The threshold
30+
* confidence for determining the type of galaxy.
2831
*/
29-
public HoughTransformer(int centerTolerance, double houghTolerance){
32+
public HoughTransformer(int centerTolerance, double houghTolerance,
33+
double houghConfidence){
3034
this.centerTolerance = centerTolerance;
3135
this.houghTolerance = houghTolerance;
36+
this.houghConfidence = houghConfidence;
3237
}
3338

3439
/**
@@ -39,7 +44,7 @@ public HoughTransformer(int centerTolerance, double houghTolerance){
3944
* @param img The image to do the processing on.
4045
* @return boolean Whether or not a circle was found.
4146
*/
42-
public void process(RenderedImage img){
47+
public Category process(RenderedImage img){
4348
int width = img.getWidth(), height = img.getHeight();
4449
float[] imgData = img.getData().getPixels(0,0, width,
4550
height, (float[])null);
@@ -53,27 +58,29 @@ public void process(RenderedImage img){
5358
LocatedCircle circle = hough.getLargestCircle(imgData,
5459
img.getWidth(), img.getHeight());
5560

61+
System.out.println(circle.getRadius());
62+
System.out.println("Location: ("+circle.getX() +"," +circle.getY());
63+
System.out.println("Confidence: " + circle.getConfidence());
5664
/**
5765
* Check that the circle we're looking for is near the center.
5866
* If it is not, then the hough transform probably found
5967
* a larger object than the one in question and failed.
6068
*/
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)
6371
|| (circY < height-centerTolerance || circY>height+centerTolerance))
6472
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;
6975
}
7076

7177

7278
public static void main(String args[]){
7379
if(args.length < 1)
7480
System.exit(1);
7581

76-
HoughTransformer trans = new HoughTransformer();
82+
//The last parameter is a placeholder for now
83+
HoughTransformer trans = new HoughTransformer(100, .70, 100.0);
7784

7885
try{
7986
trans.process(ImageIO.read(new File(args[0])));

ImageProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void main(String args[]){
2121
processor.add(new MorphologicalCloseProcess());
2222
processor.add(new GrayConvertProcess());
2323
processor.add(new MonoscaleProcess());
24-
// processor.add(new SobelDetectionProcess());
24+
processor.add(new SobelDetectionProcess());
2525

2626
for(int n = 0; n < args.length; n++){
2727
String inputFilename = args[n];

0 commit comments

Comments
 (0)