private void transposePicture() { final Picture transposedPicture = new Picture(picture.height(), picture.width()); final int width = transposedPicture.width(); final int height = transposedPicture.height(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { transposedPicture.set(i, j, picture.get(j, i)); } } picture = transposedPicture; }
// remove vertical seam from current picture public void removeVerticalSeam(final int[] seam) { checkSeam(seam, height(), width()); final int width = width() - 1; final int height = height(); final Picture newPicture = new Picture(width, height); for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { int index; if (i < seam[j]) { index = i; } else { index = i + 1; } final Color color = picture.get(index, j); newPicture.set(i, j, color); } } picture = newPicture; }