Exemple #1
0
  public boolean ManipBoxPattern(int xMin, int yMin, int xMax, int yMax, double amount) {
    int x;
    int y;
    y = yMin;
    while (y < yMax) {
      x = xMin;
      while (x < xMax) {
        Pixel p = this.getPixel(x, y);
        int yOffset = Math.abs(yMin - y);
        int xOffset = Math.abs(xMin - x);

        double ra = normal(x, xMin, xMax);

        if (ra >= 1.0) {

          int R = (int) (p.getRed() * amount);
          int G = (int) (p.getGreen() * amount);
          int B = (int) (255 * amount);

          p.setRed(R);
          p.setGreen(G);
          p.setBlue(B);

          p.getColor().brighter();
        } else {

          int R = (int) (p.getRed() * amount);
          int G = (int) (255 * amount);
          int B = (int) (p.getBlue() * amount);

          p.setRed(R);
          p.setGreen(G);
          p.setBlue(B);
        }

        if (x % 2 == 0) {

          int R = (int) (255 * amount);
          int G = (int) (p.getGreen() * amount);
          int B = (int) (p.getBlue() * amount);

          p.setRed(R);
          p.setGreen(G);
          p.setBlue(B);
        }
        x = x + 1;
      }
      y = y + 1;
    }

    return true;
  }
Exemple #2
0
 public void zeroRed() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       pixelObj.setRed(0);
     }
   }
 }
 public void keepOnlyBlue() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       pixelObj.setRed(0);
       pixelObj.setGreen(0);
     }
   }
 }
Exemple #4
0
 public void negate() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       pixelObj.setRed(255 - pixelObj.getRed());
       pixelObj.setGreen(255 - pixelObj.getGreen());
       pixelObj.setBlue(255 - pixelObj.getBlue());
     }
   }
 }
Exemple #5
0
 public void grayscale() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       int ave = (pixelObj.getRed() + pixelObj.getGreen() + pixelObj.getBlue()) / 3;
       pixelObj.setBlue(ave);
       pixelObj.setRed(ave);
       pixelObj.setGreen(ave);
     }
   }
 }
Exemple #6
0
  // changes the image to a Grayscale
  public void Grayscale() {
    Pixel[][] pixels = this.getPixels2D();
    for (Pixel[] rowArray : pixels) {
      for (Pixel pixelObj : rowArray) {

        int average = (int) pixelObj.getAverage();
        pixelObj.setGreen(average);
        pixelObj.setBlue(average);
        pixelObj.setRed(average);
      }
    }
  }
 public void negate() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       int a = pixelObj.getRed();
       int b = pixelObj.getBlue();
       int c = pixelObj.getGreen();
       pixelObj.setRed(255 - a);
       pixelObj.setBlue(255 - b);
       pixelObj.setGreen(255 - c);
     }
   }
 }
Exemple #8
0
 // implements max red to only the right side of the image
 public void rightRed() {
   Pixel[][] pixels = this.getPixels2D();
   Pixel leftPixel = null;
   Pixel rightPixel = null;
   int width = pixels[0].length;
   for (int row = 0; row < pixels.length; row++) {
     for (int col = 0; col < width / 2; col++) {
       leftPixel = pixels[row][col];
       rightPixel = pixels[row][width - 1 - col];
       rightPixel.setRed(255);
     }
   }
 }
 public void greyscale() {
   Pixel[][] pixels = this.getPixels2D();
   for (Pixel[] rowArray : pixels) {
     for (Pixel pixelObj : rowArray) {
       int a = pixelObj.getRed();
       int b = pixelObj.getBlue();
       int c = pixelObj.getGreen();
       int d = (a + b + c) / 3;
       pixelObj.setRed(d);
       pixelObj.setBlue(d);
       pixelObj.setGreen(d);
     }
   }
 }
Exemple #10
0
  public void randomColor() {
    Pixel[][] pixels = this.getPixels2D();
    for (Pixel[] row : pixels) {
      for (Pixel currentPixel : row) {
        int randomRed, randomBlue, randomGreen;
        randomRed = (int) (Math.random() * 256);
        randomBlue = (int) (Math.random() * 256);
        randomGreen = (int) (Math.random() * 256);

        currentPixel.setBlue(randomBlue);
        currentPixel.setRed(randomRed);
        currentPixel.setGreen(randomGreen);
      }
    }
  }