diff --git a/README.md b/README.md
index 33df90a..293d2be 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ DEVICE=1
# 21 - 25 = Reduce1 - Reduce5 respectively
# 30 = All Prefix related implementations at once
# 31 - 32 = Prefix1 - Prefix2 respectively
+# 40 = Rauschfilter (Spawns a javafx window)
# DEFAULT = 0
TARGET=31
diff --git a/pom.xml b/pom.xml
index d9d1262..f7f95c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,6 +18,10 @@
17
+
@@ -26,6 +30,13 @@
3.0.0
+
+
+ org.openjfx
+ javafx-controls
+ 17.0.1
+
+
junit
junit
diff --git a/src/main/java/edu/thi/phga/aparapi_test/App.java b/src/main/java/edu/thi/phga/aparapi_test/App.java
index c9cd070..698a88b 100644
--- a/src/main/java/edu/thi/phga/aparapi_test/App.java
+++ b/src/main/java/edu/thi/phga/aparapi_test/App.java
@@ -2,6 +2,8 @@ package edu.thi.phga.aparapi_test;
import com.aparapi.device.OpenCLDevice;
+import javafx.application.Application;
+
public class App {
public static int choice;
public static OpenCLDevice device;
@@ -95,6 +97,9 @@ public class App {
java.util.Arrays.fill(b, 1);
OpenCLPrefix2.start(b);
break;
+ case 40:
+ Application.launch(Rauschfilter.class);
+ break;
}
}
}
diff --git a/src/main/java/edu/thi/phga/aparapi_test/Devices.java b/src/main/java/edu/thi/phga/aparapi_test/Devices.java
index c65b57b..ed43182 100644
--- a/src/main/java/edu/thi/phga/aparapi_test/Devices.java
+++ b/src/main/java/edu/thi/phga/aparapi_test/Devices.java
@@ -1,3 +1,4 @@
+// Author: Prof. Dr. Schmidt
package edu.thi.phga.aparapi_test;
import java.io.IOException;
diff --git a/src/main/java/edu/thi/phga/aparapi_test/Rauschfilter.java b/src/main/java/edu/thi/phga/aparapi_test/Rauschfilter.java
new file mode 100644
index 0000000..38348de
--- /dev/null
+++ b/src/main/java/edu/thi/phga/aparapi_test/Rauschfilter.java
@@ -0,0 +1,61 @@
+package edu.thi.phga.aparapi_test;
+
+import java.util.Arrays;
+import java.util.stream.IntStream;
+
+import javafx.geometry.Rectangle2D;
+import javafx.scene.Scene;
+import javafx.scene.canvas.Canvas;
+import javafx.scene.canvas.GraphicsContext;
+import javafx.scene.layout.VBox;
+import javafx.stage.Screen;
+import javafx.stage.Stage;
+
+public class Rauschfilter extends javafx.application.Application {
+ private static Rectangle2D bounds = Screen.getPrimary().getBounds();
+
+ private static final int BREITE = (int) (bounds.getWidth() * 0.8);
+ private static final int HOEHE = BREITE * 9 / 16;
+
+ private static final double OMEGA = 8 * Math.PI / BREITE;
+ private static final int FILTERLAENGE = 15;
+
+ @Override
+ public void start(Stage stage) {
+ float[] noisy = new float[BREITE];
+ // float[] clean = new float[BREITE];
+
+ for (int i = 0; i < BREITE; i++) {
+ noisy[i] = (float) (5 * Math.sin(i * OMEGA) + Math.random() - 0.5);
+ }
+
+ // Kernel k = new FilterKernel(noisy, clean)
+
+ Canvas oben = getCanvas(noisy);
+
+ VBox vbox = new VBox(oben);
+
+ vbox.setStyle("-fx-background-color: whitesmoke");
+
+ stage.setScene(new Scene(vbox));
+ stage.setTitle("KAO: Mittelwertfilter der Ordnung " + (FILTERLAENGE - 1));
+ stage.setResizable(false);
+ stage.sizeToScene();
+ stage.show();
+ }
+
+ private Canvas getCanvas(float[] curve) {
+ Canvas canvas = new Canvas(BREITE, HOEHE / 2);
+ var statistics = IntStream.range(0, curve.length)
+ .mapToDouble(i -> curve[i])
+ .summaryStatistics();
+ double max = statistics.getMax(), min = statistics.getMin();
+ double scale = HOEHE / 2 / (max - min) * 0.9;
+ double[] x = new double[BREITE], y = new double[BREITE];
+ Arrays.parallelSetAll(x, i -> i);
+ Arrays.parallelSetAll(y, i -> curve[i] * scale + HOEHE / 4);
+ GraphicsContext g = canvas.getGraphicsContext2D();
+ g.setLineWidth(2); g.strokePolyline(x, y, BREITE);
+ return canvas;
+ }
+}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 0000000..c970546
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,4 @@
+open module edu.thi.phga.aparapi_test {
+ requires javafx.controls;
+ requires aparapi;
+}
\ No newline at end of file