-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the aggregate brightness map code
git-svn-id: https://android-motion-detection.googlecode.com/svn/trunk@16 996b93ed-3e4d-4b21-1044-74bd19560d1d
- Loading branch information
1 parent
cf986f1
commit 764c359
Showing
5 changed files
with
57 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author Justin Wetherell <[email protected]> | ||
*/ | ||
public class State { | ||
private int[][] map = null; | ||
private int[] map = null; | ||
private int width; | ||
private int height; | ||
private int average; | ||
|
@@ -23,27 +23,23 @@ public State(State other) { | |
} | ||
|
||
public State(int[] data, int width, int height) { | ||
if (data==null) return; | ||
if (data==null) throw new NullPointerException(); | ||
|
||
this.map = data.clone(); | ||
this.width = width; | ||
this.height = height; | ||
|
||
// setup brightness map | ||
map = new int[height][width]; | ||
|
||
|
||
// build map and stats | ||
average = 0; | ||
for (int y = 0, xy=0; y < this.height; y++) { | ||
for (int x = 0; x < this.width; x++, xy++) { | ||
int lum = data[xy]; | ||
map[y][x] = lum; | ||
average += lum; | ||
average += data[xy];; | ||
} | ||
} | ||
average = (average / (this.width * this.height)); | ||
} | ||
|
||
public int[][] getMap() { | ||
public int[] getMap() { | ||
return map; | ||
} | ||
|
||
|
@@ -59,10 +55,10 @@ public int getHeight() { | |
public String toString() { | ||
StringBuilder output = new StringBuilder(); | ||
output.append("h="+height+" w="+width+"\n"); | ||
for (int y = 0; y < height; y++) { | ||
for (int y = 0, xy = 0; y < height; y++) { | ||
output.append('|'); | ||
for (int x = 0;x < width; x++) { | ||
output.append(map[y][x]); | ||
for (int x = 0;x < width; x++, xy++) { | ||
output.append(map[xy]); | ||
output.append('|'); | ||
} | ||
output.append("\n"); | ||
|