-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperPixel.java
More file actions
76 lines (67 loc) · 1.7 KB
/
SuperPixel.java
File metadata and controls
76 lines (67 loc) · 1.7 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.awt.Color;
/***
* A pixel is a dot that makes up part of an image.
*
* A superpixel has two attributes: a color and a size.
*
* When working with a grid of superpixels, an image can be formed by
* traversing the grid and drawing a circle having the size and color
* of the superpixel at that location.
*
* @author kentcollins
*
*/
public class SuperPixel {
private Color color;
private float size;
/**
* Create a superpixel by specifying its color. A default size of
* 7 is assigned.
*
* @param color java.awt.Color to be assigned
*/
public SuperPixel(Color color) {
this.color = color;
this.size = 7;
}
/**
* Get the color that should be used when coloring this pixel.
*
* @return java.awt.Color the color of this superpixel
*/
public Color getColor() {
return color;
}
/**
* Change the color associated with this superpixel.
*
* @param color the new color to assign
*/
public void setColor(Color color) {
this.color = color;
}
/**
* Get the size at which this superpixel should be drawn.
*
* @return the size
*/
public float getSize() {
return size;
}
/**
* Set the size of this superpixel.
*
* @param size the intended size
*/
public void setSize(float size) {
this.size = size;
}
/**
* A string holding the red, green and blue components of the current color
*/
public String toString() {
String colorString = color.toString();
String colorChannelInfoRGB = colorString.substring(colorString.indexOf('['));
return colorChannelInfoRGB;
}
}