-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintEnergy.java
35 lines (26 loc) · 1.07 KB
/
PrintEnergy.java
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
34
/******************************************************************************
* Compilation: javac PrintEnergy.java
* Execution: java PrintEnergy input.png
* Dependencies: SeamCarver.java
*
*
* Read image from file specified as command line argument. Print energy
* of each pixel as calculated by SeamCarver object.
*
******************************************************************************/
import edu.princeton.cs.algs4.Picture;
import edu.princeton.cs.algs4.StdOut;
public class PrintEnergy {
public static void main(String[] args) {
Picture picture = new Picture(args[0]);
StdOut.printf("image is %d pixels wide by %d pixels high.\n", picture.width(),
picture.height());
SeamCarver sc = new SeamCarver(picture);
StdOut.printf("Printing energy calculated for each pixel.\n");
for (int row = 0; row < sc.height(); row++) {
for (int col = 0; col < sc.width(); col++)
StdOut.printf("%9.0f ", sc.energy(col, row));
StdOut.println();
}
}
}