aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/Main.java')
-rw-r--r--src/main/java/Main.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000..43571bb
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,51 @@
1/**
2 * @author Pacien TRAN-GIRARD
3 * @author Timothée FLOURE
4 */
5public final class Main {
6
7 public static void main(String[] args) {
8
9 // Load image
10 System.out.println("Load image...");
11 int[][] image = Helper.read("doves.jpg");
12 Helper.show(image, "Original");
13
14 // Convert to grayscale
15 System.out.println("Convert to grayscale...");
16 float[][] gray = Color.toGray(image);
17 Helper.show(Color.toRGB(gray), "Grayscale");
18
19 // Smooth it
20 System.out.println("Smooth image...");
21 float[][] smooth = Filter.smooth(gray);
22 Helper.show(Color.toRGB(smooth), "Smooth");
23
24 // Apply Sobel
25 System.out.println("Compute Sobel filter...");
26 float[][] sobel = Filter.sobel(smooth);
27 Helper.show(Color.toRGB(sobel), "Sobel");
28
29 // Find best seam
30 System.out.println("Find best seam...");
31 int[] seam = Seam.find(sobel);
32 Helper.show(Seam.merge(image, seam), "Best seam");
33
34 // Shrink until it is a square
35 int count = image[0].length - image.length;
36 System.out.println("Shrink by removing " + count + " seams...");
37 for (int i = 0; i < count; ++i) {
38 sobel = Filter.sobel(Filter.smooth(Color.toGray(image)));
39 seam = Seam.find(sobel);
40 image = Seam.shrink(image, seam);
41 System.out.println("Seam " + (i + 1) + "/" + count);
42 }
43 System.out.println("Done");
44 Helper.show(image, "Shrink");
45
46 // Save result
47 Helper.write("doves.shrink.jpg", image);
48
49 }
50
51}