summaryrefslogtreecommitdiffstats
path: root/Algorithms/Part-II/2-SeamCarving/PrintEnergy.java
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-12-12 15:40:02 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-12-12 15:40:02 +0100
commite1ec44b3078a20c4e7ab85e30083063205159761 (patch)
tree195bad21bd885dc6a1f78ba741b16a1355ef4d92 /Algorithms/Part-II/2-SeamCarving/PrintEnergy.java
parenta60ba769f451259caba14886fdb206593b92df76 (diff)
downloadcoursera-e1ec44b3078a20c4e7ab85e30083063205159761.zip
coursera-e1ec44b3078a20c4e7ab85e30083063205159761.tar.gz
Algorithms-II : 2-SeamCarving: add prototypes and data
Diffstat (limited to 'Algorithms/Part-II/2-SeamCarving/PrintEnergy.java')
-rw-r--r--Algorithms/Part-II/2-SeamCarving/PrintEnergy.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/Algorithms/Part-II/2-SeamCarving/PrintEnergy.java b/Algorithms/Part-II/2-SeamCarving/PrintEnergy.java
new file mode 100644
index 0000000..ff01565
--- /dev/null
+++ b/Algorithms/Part-II/2-SeamCarving/PrintEnergy.java
@@ -0,0 +1,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();
+ }
+ }
+
+}