Example #1
0
  public void deleteVerticaltwoPath() {

    this.interest = this.verticalInterest(image);

    Suurballe sb = new Suurballe();
    Graph g = this.verticalToGraph2(interest);

    // recherche des chemins
    ArrayList<Integer> chemin = sb.rechercheChemin(g, 0, g.vertices() - 1, this.interest);

    ArrayList<Integer> chemin1 = new ArrayList<>();
    ArrayList<Integer> chemin2 = new ArrayList<>();
    boolean end1 = false;

    for (int i = 0; i < chemin.size(); i++) {
      if (!end1) {
        if (chemin.get(i) != -1) {
          chemin1.add(chemin.get(i));
        } else {
          end1 = true;
        }
      } else {
        chemin2.add(chemin.get(i));
      }
    }

    this.tabDeleteColum(chemin1, chemin2);
  }
Example #2
0
  public void deleteLines() {

    this.interest = this.HorizontalInterest(image);
    int nbPixels = height * width;

    Dijkstra d = new Dijkstra();
    Graph g = this.horizontalToGraph(this.interest);

    ArrayList<Integer> res = d.rechercheChemin(g, 0, g.vertices() - 1);

    int[][] newImage = new int[height - 1][width];
    int[][][] newImageColor = new int[height - 1][width][3];

    int line;
    int column = width - 1;
    boolean equals;
    int pos, k;

    for (int l : res) {
      line = 0;
      pos = l % this.height - 1;
      if (pos == -1) {
        pos = this.height - 1;
      }
      equals = false;

      if (l != 0 && l != (nbPixels + 1)) {
        while (line != this.height - 1) {
          if (pos == line) {
            equals = true;
          }

          if (equals == false) {
            if (color) {
              for (k = 0; k < 3; k++)
                newImageColor[line][column][k] = this.imageRgb[line][column][k];
            } else newImage[line][column] = this.image[line][column];
          } else if (equals == true) {
            if (column < width) {
              if (color) {
                for (k = 0; k < 3; k++)
                  newImageColor[line][column][k] = this.imageRgb[line + 1][column][k];
              } else newImage[line][column] = this.image[line + 1][column];
            }
          } else {
            System.err.println("Error 0x087A4E652");
          }
          line++;
        }
      }
      column--;
    }

    if (color) this.imageRgb = newImageColor;
    else this.image = newImage;

    this.height = height - 1;
  }
Example #3
0
  public void addLines() {

    this.interest = this.HorizontalInterest(image);
    int nbPixels = height * width;

    Dijkstra d = new Dijkstra();
    Graph g = this.horizontalToGraph(this.interest);

    ArrayList<Integer> res = d.rechercheChemin(g, 0, g.vertices() - 1);

    int[][] newImage = new int[height + 1][width];

    int line;
    int column = width - 1;
    boolean equals;
    int pos;

    for (int l : res) {
      line = 0;
      pos = l % this.height - 1;
      if (pos == -1) {
        pos = this.height - 1;
      }
      equals = false;

      if (l != 0 && l != (nbPixels + 1)) {
        while (line != this.height + 1) {
          if (pos == line) {
            equals = true;
          }

          if (equals == false) {
            newImage[line][column] = this.image[line][column];
          } else if (equals == true) {
            // Ajout premiere ligne de pixels
            if (line == pos) {
              if (line > 0) {
                int highPixel = this.image[line - 1][column];
                int currentPixel = this.image[line][column];
                newImage[line][column] = (highPixel + currentPixel) / 2;
              } else {
                newImage[line][column] = this.image[line][column];
              }
            }
            // ajout deuxieme ligne de pixels
            else if (line == pos + 1) {
              if (line < this.height) {
                int lowPixel = this.image[line][column];
                int currentPixel = this.image[line - 1][column];
                newImage[line][column] = (lowPixel + currentPixel) / 2;
              } else {
                newImage[line][column] = this.image[line][column];
              }
            } else if (line < width + 1) {
              newImage[line][column] = this.image[line - 1][column];
            }
          } else {
            System.err.println("Error 0x087A4E652");
          }
          line++;
        }
      }
      column--;
    }

    this.image = newImage;
    this.height = height + 1;
  }
Example #4
0
  public void addColumns() {

    this.interest = this.verticalInterest(image);
    int nbPixels = height * width;

    Dijkstra d = new Dijkstra();
    Graph g = this.verticalToGraph(this.interest);

    ArrayList<Integer> res = d.rechercheChemin(g, 0, g.vertices() - 1);

    int[][] newImage = new int[height][width + 1];

    int line = height - 1;
    int column;
    boolean equals;
    int pos;

    for (int l : res) {
      column = 0;
      pos = l % this.width - 1;
      if (pos == -1) {
        pos = this.width - 1;
      }
      equals = false;

      if (l != 0 && l != (nbPixels + 1)) {
        while (column != this.width + 1) {
          if (pos == column) {
            equals = true;
          }

          if (equals == false) {
            newImage[line][column] = this.image[line][column];
          } else if (equals == true) {
            // Ajout premiere colonne de pixels
            if (column == pos) {
              if (column > 0) {
                int leftPixel = this.image[line][column - 1];
                int currentPixel = this.image[line][column];
                newImage[line][column] = (leftPixel + currentPixel) / 2;
              } else {
                newImage[line][column] = this.image[line][column];
              }
            }
            // ajout deuxieme colonne de pixels
            else if (column == pos + 1) {
              if (column < this.width) {
                int rightPixel = this.image[line][column];
                int currentPixel = this.image[line][column - 1];
                newImage[line][column] = (rightPixel + currentPixel) / 2;
              } else {
                newImage[line][column] = this.image[line][column];
              }
            } else if (column < width + 1) {
              newImage[line][column] = this.image[line][column - 1];
            }
          } else {
            System.err.println("Error 0x087A4E652");
          }
          column++;
        }
      }
      line--;
    }

    this.image = newImage;
    this.width = width + 1;
  }