-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCAnalyzer.java
30 lines (25 loc) · 1015 Bytes
/
PCAnalyzer.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
//Given an empty image and a current image, determine how crowded Price Center is.
public class PCAnalyzer {
private static final int lazyPersonAverage()
private int numDifferentPixels = 0;
private int threshold = 10;
public void analyze (Picture reference, Picture input)
{
for (int i = 0; i < reference.width; i++)
{
for (int j = 0; j < reference.height; j++)
{
Pixel refPixel = reference.getPixel(i,j);
Pixel inputPixel = input.getPixel(i,j);
int redDiff = Math.abs(refPixel.red - inputPixel.red);
int greenDiff = Math.abs(refPixel.green - inputPixel.green);
int blueDiff = Math.abs(refPixel.blue - inputPixel.blue);
if (redDiff + greenDiff + blueDiff > threshold)
{
numDifferentPixels++;
input.setPixel(0,255,0);
}
}
}
}
}