normalize method

void normalize()

Normalize the depths for each geometry, if they are non-null. A normalized depth has depth values in the set { 0, 1 }. Normalizing the depths involves reducing the depths by the same amount so that at least one of them is 0. If the remaining value is > 0, it is set to 1.

Implementation

void normalize() {
  for (int i = 0; i < 2; i++) {
    if (!isNull1(i)) {
      int minDepth = depth[i][1];
      if (depth[i][2] < minDepth) minDepth = depth[i][2];

      if (minDepth < 0) minDepth = 0;
      for (int j = 1; j < 3; j++) {
        int newValue = 0;
        if (depth[i][j] > minDepth) newValue = 1;
        depth[i][j] = newValue;
      }
    }
  }
}