@ -1,4 +1,4 @@ |
|||||||
533 |
643 |
||||||
170 |
365 |
||||||
1459 |
1491 |
||||||
693 |
844 |
||||||
|
After Width: | Height: | Size: 735 KiB |
Before Width: | Height: | Size: 908 KiB After Width: | Height: | Size: 712 KiB |
Before Width: | Height: | Size: 938 KiB After Width: | Height: | Size: 732 KiB |
After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 6.1 KiB |
@ -0,0 +1,72 @@ |
|||||||
|
package sig; |
||||||
|
|
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Rectangle; |
||||||
|
import java.awt.image.BufferedImage; |
||||||
|
|
||||||
|
public class ColorRegion { |
||||||
|
Rectangle region; |
||||||
|
BufferedImage img; |
||||||
|
|
||||||
|
ColorRegion(BufferedImage img, Rectangle region) { |
||||||
|
this.region=region; |
||||||
|
this.img=img; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean getRedRange(int min,int max) { |
||||||
|
int avgRed = getRed(); |
||||||
|
return avgRed>=min&&avgRed<=max; |
||||||
|
} |
||||||
|
public boolean getGreenRange(int min,int max) { |
||||||
|
int avgGreen = getGreen(); |
||||||
|
return avgGreen>=min&&avgGreen<=max; |
||||||
|
} |
||||||
|
public boolean getBlueRange(int min,int max) { |
||||||
|
int avgBlue = getBlue(); |
||||||
|
return avgBlue>=min&&avgBlue<=max; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean getAllRange(int min,int max) { |
||||||
|
return getRedRange(min,max)&&getGreenRange(min,max)&&getBlueRange(min,max); |
||||||
|
} |
||||||
|
public boolean getAllRange(int minRed,int maxRed,int minGreen,int maxGreen,int minBlue,int maxBlue) { |
||||||
|
return getRedRange(minRed,maxRed)&&getGreenRange(minGreen,maxGreen)&&getBlueRange(minBlue,maxBlue); |
||||||
|
} |
||||||
|
|
||||||
|
public int getRed() { |
||||||
|
int total = 0; |
||||||
|
for (int x=0;x<region.width;x++) { |
||||||
|
for (int y=0;y<region.height;y++) { |
||||||
|
total+=new Color(img.getRGB(region.x+x, region.y+y)).getRed(); |
||||||
|
} |
||||||
|
} |
||||||
|
return total/(region.width*region.height); |
||||||
|
} |
||||||
|
public int getGreen() { |
||||||
|
int total = 0; |
||||||
|
for (int x=0;x<region.width;x++) { |
||||||
|
for (int y=0;y<region.height;y++) { |
||||||
|
total+=new Color(img.getRGB(region.x+x, region.y+y)).getGreen(); |
||||||
|
} |
||||||
|
} |
||||||
|
return total/(region.width*region.height); |
||||||
|
} |
||||||
|
public int getBlue() { |
||||||
|
int total = 0; |
||||||
|
for (int x=0;x<region.width;x++) { |
||||||
|
for (int y=0;y<region.height;y++) { |
||||||
|
total+=new Color(img.getRGB(region.x+x, region.y+y)).getBlue(); |
||||||
|
} |
||||||
|
} |
||||||
|
return total/(region.width*region.height); |
||||||
|
} |
||||||
|
|
||||||
|
public String toString() { |
||||||
|
StringBuilder sb = new StringBuilder("ColorRegion(Region: "); |
||||||
|
return sb.append(region).append(",") |
||||||
|
.append("R:").append(getRed()).append(",") |
||||||
|
.append("G:").append(getGreen()).append(",") |
||||||
|
.append("B:").append(getBlue()).append(")") |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |