-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegionsTest.java
45 lines (38 loc) · 1.23 KB
/
RegionsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Lab1;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
/**
* Testing code for region finding in PS-1.
*
* @author Chris Bailey-Kellogg, Dartmouth CS 10, Winter 2014
* @author Travis W. Peters, Dartmouth CS 10, Updated Winter 2015
* @author CBK, Spring 2015, updated for DrawingGUI
*/
public class RegionsTest extends DrawingGUI {
private BufferedImage image;
/**
* Test your RegionFinder by passing an image filename and a color to find.
* @param filename
* @param color
*/
public RegionsTest(String name, RegionFinder finder, Color targetColor) {
super(name, finder.getImage().getWidth(), finder.getImage().getHeight());
// Do the region finding and recolor the image.
finder.findRegions(targetColor);
finder.recolorRegions();
image = finder.getRecoloredImage();
}
@Override
public void draw(Graphics g) {
g.drawImage(image, 0, 0, null);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new RegionsTest("smiley", new RegionFinder(loadImage("pictures/smiley.png")), new Color(0, 0, 0));
new RegionsTest("baker", new RegionFinder(loadImage("pictures/baker.jpg")), new Color(130, 100, 100));
}
});
}
}