summaryrefslogtreecommitdiffstats
path: root/Algorithms/Part-II/2-SeamCarving/ShowSeams.java
diff options
context:
space:
mode:
Diffstat (limited to 'Algorithms/Part-II/2-SeamCarving/ShowSeams.java')
-rw-r--r--Algorithms/Part-II/2-SeamCarving/ShowSeams.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/Algorithms/Part-II/2-SeamCarving/ShowSeams.java b/Algorithms/Part-II/2-SeamCarving/ShowSeams.java
new file mode 100644
index 0000000..9fbe20a
--- /dev/null
+++ b/Algorithms/Part-II/2-SeamCarving/ShowSeams.java
@@ -0,0 +1,48 @@
+/*************************************************************************
+ * Compilation: javac ShowSeams.java
+ * Execution: java ShowSeams input.png
+ * Dependencies: SeamCarver.java SCUtility.java Picture.java StdDraw.java
+ *
+ *
+ * Read image from file specified as command line argument. Show 3 images
+ * original image as well as horizontal and vertical seams of that image.
+ * Each image hides the previous one - drag them to see all three.
+ *
+ *************************************************************************/
+
+public class ShowSeams {
+
+ private static void showHorizontalSeam(SeamCarver sc)
+ {
+ Picture ep = SCUtility.toEnergyPicture(sc);
+ int[] horizontalSeam = sc.findHorizontalSeam();
+ Picture epOverlay = SCUtility.seamOverlay(ep, true, horizontalSeam);
+ epOverlay.show();
+ }
+
+
+ private static void showVerticalSeam(SeamCarver sc)
+ {
+ Picture ep = SCUtility.toEnergyPicture(sc);
+ int[] verticalSeam = sc.findVerticalSeam();
+ Picture epOverlay = SCUtility.seamOverlay(ep, false, verticalSeam);
+ epOverlay.show();
+ }
+
+ public static void main(String[] args)
+ {
+ Picture inputImg = new Picture(args[0]);
+ System.out.printf("image is %d columns by %d rows\n",
+ inputImg.width(), inputImg.height());
+ inputImg.show();
+ SeamCarver sc = new SeamCarver(inputImg);
+
+ System.out.printf("Displaying horizontal seam calculated.\n");
+ showHorizontalSeam(sc);
+
+ System.out.printf("Displaying vertical seam calculated.\n");
+ showVerticalSeam(sc);
+
+ }
+
+}