feat: javafx dependency added, Rauschfilter (partially working)
This commit is contained in:
parent
6e15d25210
commit
d6cd29f2fc
@ -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
|
||||
|
||||
|
11
pom.xml
11
pom.xml
@ -18,6 +18,10 @@
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<!-- <modules>
|
||||
<module>aparapi_test</module>
|
||||
</modules>
|
||||
-->
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.aparapi/aparapi -->
|
||||
<dependency>
|
||||
@ -26,6 +30,13 @@
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>17.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Author: Prof. Dr. Schmidt <Ulrich.Schmidt@thi.de>
|
||||
package edu.thi.phga.aparapi_test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
61
src/main/java/edu/thi/phga/aparapi_test/Rauschfilter.java
Normal file
61
src/main/java/edu/thi/phga/aparapi_test/Rauschfilter.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
4
src/main/java/module-info.java
Normal file
4
src/main/java/module-info.java
Normal file
@ -0,0 +1,4 @@
|
||||
open module edu.thi.phga.aparapi_test {
|
||||
requires javafx.controls;
|
||||
requires aparapi;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user