summaryrefslogtreecommitdiffstats
path: root/Algorithms/Part-II/2-SeamCarving/PrintEnergy.java
blob: ff01565daa6f71d25400e16c638f304ba5bf4a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*************************************************************************
 *  Compilation:  javac PrintEnergy.java
 *  Execution:    java PrintEnergy input.png
 *  Dependencies: SeamCarver.java Picture.java StdDraw.java
 *
 *
 *  Read image from file specified as command line argument. Print energy
 *  of each pixel as calculated by SeamCarver object.
 *
 *************************************************************************/

public class PrintEnergy {

    public static void main(String[] args)
    {
        Picture inputImg = new Picture(args[0]);
        System.out.printf("image is %d pixels wide by %d pixels high.\n",
                          inputImg.width(), inputImg.height());

        SeamCarver sc = new SeamCarver(inputImg);

        System.out.printf("Printing energy calculated for each pixel.\n");

        for (int j = 0; j < sc.height(); j++)
        {
            for (int i = 0; i < sc.width(); i++)
                System.out.printf("%9.0f ", sc.energy(i, j));

            System.out.println();
        }
    }

}