/** Test Main. It will explore Splatoon! */
 public static void main(String args[]) {
   // Picture pix = new Picture("snowman.jpg");
   Picture pix = new Picture("splatoon.jpg");
   Picture smallPic = pix.scale(.5, .48);
   smallPic.explore();
   smallPic.write("smallSplatoon.jpg");
 }
 public static void main(String[] args) {
   Picture p = new Picture(FileChooser.getMediaPath("horse.jpg"));
   Graphics g = p.getGraphics();
   Point ul = new Point(68, 24);
   Point te = new Point(182, 123);
   String message = "This is a test." + "  Of a message with more than one line in it.";
   SpeechBalloon balloon = new SpeechBalloon(ul, 200, te, message);
   balloon.draw(g);
   p.show();
 }
  public SeamCarver(Picture picture) {
    // create a seam carver object based on the given picture
    int picWidth = picture.width();
    int picHeight = picture.height();
    currentPicture = picture;
    pixelColor = new Color[picWidth][picHeight];

    for (int i = 0; i < picHeight; i++) {
      for (int j = 0; j < picWidth; j++) {
        pixelColor[j][i] = picture.get(j, i);
      }
    }
  }
Example #4
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture beach = new Picture("beach.jpg");
    beach.explore();
    beach.mirrorVerticalBottomToTop();
    // beach.mirrorVerticalRightToLeft();
    // beach.Grayscale();
    // beach.maxBlue();
    // beach.createCollage();
    // beach.rightRed();
    beach.explore();
    // beach.write("5FilterBeach.jpeg");

  }
Example #5
0
 /** Method to create a collage of several pictures */
 public void createCollage() {
   Picture flower1 = new Picture("flower1.jpg");
   Picture flower2 = new Picture("flower2.jpg");
   this.copy(flower1, 0, 0);
   this.copy(flower2, 100, 0);
   this.copy(flower1, 200, 0);
   Picture flowerNoBlue = new Picture(flower2);
   flowerNoBlue.zeroBlue();
   this.copy(flowerNoBlue, 300, 0);
   this.copy(flower1, 400, 0);
   this.copy(flower2, 500, 0);
   this.mirrorVertical();
   this.write("collage.jpg");
 }
Example #6
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture desert = new Picture("Desert.jpg");
    Picture koala = new Picture("Koala.jpg");
    //    beach.explore();
    //    beach.zeroBlue();
    //    desert.chromakey(koala);
    //    desert.sepia(25, 3);
    koala.sepia();
    //    desert.encode("ABCDEFGHIJKLMNOPasdfgwe6");
    //    System.out.println(desert.decode());

    //    desert.explore();
    koala.explore();
  }
Example #7
0
 public void cropAndCopy(
     Picture sourcePicture,
     int startSourceRow,
     int endSourceRow,
     int startSourceCol,
     int endSourceCol,
     int startDestRow,
     int startDestCol) {
   Pixel leftPixel = null;
   Pixel rightPixel = null;
   Pixel[][] pixels = this.getPixels2D();
   Color rightColor = null;
   Pixel[][] fromPixels = sourcePicture.getPixels2D();
   Pixel[][] toPixels = this.getPixels2D();
   Pixel fromPixel = null;
   Pixel toPixel = null;
   for (int fromRow = startSourceRow, toRow = endSourceRow;
       fromRow < fromPixels.length && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = startSourceCol, toCol = endSourceCol;
         fromCol < fromPixels[0].length && toCol < toPixels[0].length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
Example #8
0
 /**
  * Method to replace blue pixels with pixels from the second picture.
  *
  * @param second picture to replace blue pixels with
  */
 public void chromakey(Picture second) {
   Pixel[][] pixels = this.getPixels2D();
   Pixel[][] pixels2 = second.getPixels2D();
   for (int row = 0; row < pixels.length; row++)
     for (int col = 0; col < pixels[0].length; col++)
       if (pixels[row][col].getColor().getBlue() >= 200)
         pixels[row][col].setColor(pixels2[row][col].getColor());
 }
Example #9
0
  /**
   * Method to create a new picture by scaling the current picture by the given x and y factors
   *
   * @param xFactor the amount to scale in x
   * @param yFactor the amount to scale in y
   * @return the resulting picture
   */
  public Picture scale(double xFactor, double yFactor) {
    // set up the scale transform
    AffineTransform scaleTransform = new AffineTransform();
    scaleTransform.scale(xFactor, yFactor);

    // create a new picture object that is the right size
    Picture result = new Picture((int) (getWidth() * xFactor), (int) (getHeight() * yFactor));

    // get the graphics 2d object to draw on the result
    Graphics graphics = result.getGraphics();
    Graphics2D g2 = (Graphics2D) graphics;

    // draw the current image onto the result image scaled
    g2.drawImage(this.getImage(), scaleTransform, null);

    return result;
  }
Example #10
0
  private Picture initialImage() {
    pic2 = new Picture(500, 600);
    pic1 = new Picture(500, 600);

    for (int x = 0; x < pic2.width(); x++)
      for (int y = 0; y < pic2.height(); y++) {
        double dist = 1.0 - Math.sqrt((x - 300) * (x - 300) + (y - 200) * (y - 200)) / 500;
        int red =
            (int)
                (dist < 0.5
                    ? 0
                    : Math.min(Math.pow(dist, 0.4) + Math.pow(dist - 0.5, 0.1), 1.0) * 255);
        int green = (int) (dist * 255);
        int blue = 0;
        pic2.set(x, y, new Color(red, green, blue));
      }
    return pic2;
  }
Example #11
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }
Example #12
0
 public static void main(String[] args) {
   int width = Integer.parseInt(args[0]);
   int height = Integer.parseInt(args[1]);
   Picture pic = new Picture(width, height);
   int count = 0;
   for (int i = 0; i < height; i++) {
     for (int j = 0; j < width; j++) {
       pic.set(j, i, Color.RED);
       if (!BinaryStdIn.isEmpty()) {
         count++;
         boolean bit = BinaryStdIn.readBoolean();
         if (bit) pic.set(j, i, Color.BLACK);
         else pic.set(j, i, Color.WHITE);
       }
     }
   }
   pic.show();
   StdOut.println(count + " bits");
 }
  private void CreatePictureFromColorMatrix(int width, int height) {
    verticalSeamCarve = new Picture(width, height);
    for (int i = 0; i < width; i++) {
      for (int j = 0; j < height; j++) {
        verticalSeamCarve.set(i, j, pixelColor[i][j]);
      }
    }

    currentPicture = verticalSeamCarve;
  }
Example #14
0
 public static void main(String[] args) {
   String fileName = FileChooser.pickAFile();
   Picture pictObj = new Picture(fileName);
   pictObj.changeWhole(.5);
   pictObj.changeWhole(.8);
   pictObj.scrible(200, 200, 50);
   pictObj.scrible(350, 320, 100);
   pictObj.ManipBoxUniformly(200, 200, 300, 300, .2);
   pictObj.ManipBoxUniformly(100, 100, 400, 300, .5);
   pictObj.ManipBoxPattern(100, 100, 300, 300, .3);
   pictObj.ManipBoxPattern(300, 300, 400, 400, .8);
   pictObj.explore();
 }
Example #15
0
 /**
  * copy from the passed fromPic to the specified startRow and startCol in the current picture
  *
  * @param fromPic the picture to copy from
  * @param startRow the start row to copy to
  * @param startCol the start col to copy to
  */
 public void copy(Picture fromPic, int startRow, int startCol) {
   Pixel fromPixel = null;
   Pixel toPixel = null;
   Pixel[][] toPixels = this.getPixels2D();
   Pixel[][] fromPixels = fromPic.getPixels2D();
   for (int fromRow = 0, toRow = startRow;
       fromRow < fromPixels.length && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = 0, toCol = startCol;
         fromCol < fromPixels[0].length && toCol < toPixels[0].length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
Example #16
0
 public void copy(
     Picture fromPic,
     int fromStartRow,
     int fromStartCol,
     int toStartRow,
     int toStartCol,
     int fromEndRow,
     int fromEndCol) {
   Pixel fromPixel = null;
   Pixel toPixel = null;
   Pixel[][] toPixels = this.getPixels2D();
   Pixel[][] fromPixels = fromPic.getPixels2D();
   for (int fromRow = fromStartRow, toRow = toStartRow;
       fromRow <= fromEndRow && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = fromStartCol, toCol = toStartCol;
         fromCol <= fromEndCol && toCol < toPixels.length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
Example #17
0
  /** Method to create a collage of several pictures */
  public void createCollage() {
    Picture pic2 = new Picture("moon-surface.jpg");

    Picture picNoBlue = new Picture(pic2);
    picNoBlue.zeroBlue();

    Picture effect1 = new Picture(pic2);
    effect1.edgeDetection(10);

    Picture effect2 = new Picture(pic2);

    this.copy(effect1, 250, 600);
    this.copy(pic2, 0, 600);
    effect2.mirrorVertical();
    this.copy(effect2, 250, 0);

    this.copy(picNoBlue, 0, 0);

    this.write("collage.jpg");
  }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("connor.jpg");
   Picture smallP = pix.scale(0.1, 0.1);
   smallP.write("smallPictures.jpg");
   pix.explore();
 }
 public int height() {
   // height of current picture
   return currentPicture.height();
 }
 public int width() {
   // width of current picture
   return currentPicture.width();
 }
Example #21
0
 /* Main method for testing - each class in Java can have a main
  * method
  */
 public static void main(String[] args) {
   Picture beach = new Picture("beach.jpg");
   beach.explore();
   beach.zeroBlue();
   beach.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("seagull.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("Bknight.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("Russet_Potato.jpg");
   pix.explore();
 }
Example #25
0
 /* Main method for testing - each class in Java can have a main
  * method
  */
 public static void main(String[] args) {
   Picture beach = new Picture("pixLab/images/beach.jpg");
   beach.explore();
   beach.keepOnlyRed();
   beach.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("D://Documents/ApComputers/pixLab/images/beach.jpg");
   pix.explore();
 }