public SeamCarver(Picture picture) {
        width = picture.width();
        height = picture.height();
        transposed = false;
        img = new int[height][width];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                img[y][x] = picture.get(x, y).getRGB();
            }
        }
        energy = new double[height][width];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                energy[y][x] = energy(x, y);
            }
        }
    }