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; }
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 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; }