Пример #1
0
  public Letter getIntersection() {
    try {
      // int xx = this.imgOffset[0];
      // int yy = this.imgOffset[1];
      int left = offset[0];
      int top = offset[1];
      int tmpIntersectionWidth = intersectionDimension[0];
      int tmpIntersectionHeight = intersectionDimension[1];

      // long starter=Utilities.getTimer();

      int[][] g = new int[tmpIntersectionWidth][tmpIntersectionHeight];

      for (int x = 0; x < tmpIntersectionWidth; x++) {
        for (int y = 0; y < tmpIntersectionHeight; y++) {
          g[x][y] = a.getPixelValue(x + left, y + top);
        }
      }

      Letter ret = getA().createLetter();
      int[] l = getA().getLocation();
      ret.setLocation(new int[] {l[0] + left, l[1] + top});
      ret.setGrid(g);
      ret.clean();
      return ret;
    } catch (Exception e) {
      JDLogger.exception(e);
      return getA();
    }
  }
Пример #2
0
  /**
   * Gib zurück ob es sich um einen gemeinsammenpixel handekt oder nicht
   *
   * @param x
   * @param y
   * @param xx
   * @param yy
   * @param left
   * @param top
   * @return -2(fehler)/ 0 gemeinsammer schwarzer Pixel /1 Pixel B aber nicht a / 2 pixel A aber
   *     nicht B/ -1 beide weiß
   */
  public int getPixelType(int x, int y, int xx, int yy, int left, int top) {

    int va = a.getPixelValue(x + left, y + top);
    bc = coordinatesFromAToB(x + left, y + top, xx, yy, bc);
    int vb = b.getPixelValue(bc[0], bc[1]);
    if (va < 0 || vb < 0) {
      return -2;
    }
    if (vb == 0 && va == 0) {
      return 0;
    } else if (vb == 0) {
      return 1;
    } else if (va == 0) {

      return 2;
    }
    return -1;
  }
Пример #3
0
  /**
   * returns the open circle
   *
   * @return
   */
  public Letter getOpenCircle() {
    if (openCircle != null) {
      return openCircle;
    }
    // Graphics g = image.getGraphics();
    // g.setColor(Color.black);
    // g.drawOval(55, 55, 18, 18);
    getCircles();
    // if(true)return null;
    Letter best = null;
    int bestwda = Integer.MIN_VALUE;
    for (PixelObject pixelObject : objectArray) {
      Letter let = pixelObject.toColoredLetter();
      int w = 0;

      for (int x = 0; x < let.getWidth(); x++) {
        for (int y = 0; y < let.getHeight(); y++) {
          if (isBackground(let.getPixelValue(x, y))) {
            w++;
          } else {
            break;
          }
        }
      }

      for (int y = 0; y < let.getHeight(); y++) {
        for (int x = 0; x < let.getWidth(); x++) {
          if (isBackground(let.getPixelValue(x, y))) {
            w++;
          } else {
            break;
          }
        }
      }

      for (int x = 0; x < let.getWidth(); x++) {
        for (int y = let.getHeight() - 1; y > 0; y--) {
          if (isBackground(let.getPixelValue(x, y))) {
            w++;
          } else {
            break;
          }
        }
      }

      for (int y = 0; y < let.getHeight(); y++) {
        for (int x = let.getWidth() - 1; x > 0; x--) {
          if (isBackground(let.getPixelValue(x, y))) {
            w++;
          } else {
            break;
          }
        }
      }

      int wda = w * 100 / let.getArea();
      BasicWindow.showImage(pixelObject.toColoredLetter().getImage(), "" + wda);
      // TODO
      if (wda > bestwda && let.getArea() > minArea) {

        best = let;
        bestwda = wda;
      }
    }
    openCircle = best;
    return best;
  }