Skip to content

Instantly share code, notes, and snippets.

@ns
Created December 6, 2011 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ns/1436242 to your computer and use it in GitHub Desktop.
Save ns/1436242 to your computer and use it in GitHub Desktop.
public static int[][] detectVarianceCrossing(int[][] zeroCrossingImgData, int[][] secondOrderDrvImgData, int[][] gaussianImgData) {
int threshold = 60000;
int[][] result = new int[zeroCrossingImgData.length][zeroCrossingImgData[0].length];
for (int x = 0; x < zeroCrossingImgData.length; x++) {
for (int y = 0; y < zeroCrossingImgData[0].length; y++) {
int val = zeroCrossingImgData[y][x];
result[y][x] = 0;
if (val == 255) {
if (x > 0) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else if (y > 0) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else if (x > 0 && y > 0) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else if (x < zeroCrossingImgData.length-1) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else if (y < zeroCrossingImgData[0].length-1) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else if (x < zeroCrossingImgData.length-1 && y < zeroCrossingImgData[0].length-1) {
result[y][x] += Math.pow(secondOrderDrvImgData[y][x] - gaussianImgData[y][x], 2);
}
else {
result[y][x] += 0;
}
if (result[y][x] < threshold) {
result[y][x] = 0;
}
}
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment