public MickeyMouseGrid2D(int x, int y, int phase) {
    super(x, y, "MickeyMouseGrid2D");

    int val1 = 1;
    int val2 = 2;
    double r1 = 0.4 * x;
    double r2 = 0.2 * x;
    int xCenter1 = x / 2;
    int yCenter1 = 6 * y / 10;

    int xCenter2 = (int) (0.25 * x);
    int yCenter2 = (int) (0.15 * y);
    int xCenter3 = (int) (0.75 * x);
    int yCenter3 = (int) (0.15 * y);

    for (int i = 0; i < x; i++) {
      for (int j = 0; j < y; j++) {

        if (phase > 2)
          if (Math.pow(i - xCenter2, 2) + Math.pow(j - yCenter2, 2) <= (r2 * r2)) {
            super.setAtIndex(i, j, val2);
          }
        if (phase > 1)
          if (Math.pow(i - xCenter3, 2) + Math.pow(j - yCenter3, 2) <= (r2 * r2)) {
            super.setAtIndex(i, j, val2);
          }
        if (phase > 0)
          if (Math.pow(i - xCenter1, 2) + Math.pow(j - yCenter1, 2) <= (r1 * r1)) {
            super.setAtIndex(i, j, val1);
          }
      }
    }
  }
Beispiel #2
0
  private void CreatePhantom() {

    // Iterate over all pixels and sum up intensity values of all corresponding ellipses
    double sizeX = (double) super.getSize()[0];
    double sizeY = (double) super.getSize()[1];

    for (int i = 0; i < super.getSize()[0]; ++i) {
      double x = ((double) i - (sizeX - 1) / 2.0) / ((sizeX - 1) / 2.0);
      for (int j = 0; j < super.getSize()[1]; ++j) {
        double y = ((double) j - (sizeY - 1) / 2.0) / ((sizeY - 1) / 2.0);
        super.setAtIndex(i, super.getSize()[1] - j - 1, 0.f);
        for (int k = 0; k < Ellipses.getRows(); ++k) {
          // Extract the ellipse properties here
          double xc = x - Ellipses.getElement(k, 3);
          double yc = y - Ellipses.getElement(k, 4);
          double phi = Ellipses.getElement(k, 5) * Math.PI / 180.0;
          double cos = Math.cos(phi);
          double sin = Math.sin(phi);
          double asq = Ellipses.getElement(k, 1) * Ellipses.getElement(k, 1);
          double bsq = Ellipses.getElement(k, 2) * Ellipses.getElement(k, 2);
          double Val = Ellipses.getElement(k, 0);

          // Check if this pixel is part of the ellipse, if yes, add the given intensity value to it
          double help = Math.pow((xc * cos + yc * sin), 2.0);
          double help2 = Math.pow((yc * cos - xc * sin), 2.0);
          if (help / asq + help2 / bsq <= 1.0)
            super.setAtIndex(
                i,
                super.getSize()[1] - j - 1,
                super.getAtIndex(i, super.getSize()[1] - j - 1) + (float) Val);
        }
      }
    }
  }