public int getValue(int pos) {
    int b = (int) (pos / (width * height));
    pos -= b * width * height;
    int y = (int) (pos / width);
    int x = pos % width;

    return outImage.getSample(x, y, b);
  }
  protected void setValue(int pos, int val) {

    int b = (int) (pos / (width * height));
    pos -= b * width * height;
    int y = (int) (pos / width);
    int x = pos % width;

    outImage.setSample(x, y, b, val);
  }
  protected void setValue(int pos, int sign, int tt) {
    int s = (sign == QuadOutputStream.PLUS) ? 1 : -1;

    int b = (int) (pos / (width * height));
    pos -= b * width * height;
    int y = (int) (pos / width);
    int x = pos % width;

    outImage.setSample(x, y, b, s * tt);
  }