-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize.scala
More file actions
46 lines (35 loc) · 1.27 KB
/
visualize.scala
File metadata and controls
46 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//> using scala "3.3"
//> using dep "ch.unibas.cs.gravis::scalismo-ui:0.92.0"
import scalismo.io.StatisticalModelIO
import scalismo.ui.api.ScalismoUI
import scalismo.geometry._
import scalismo.common._
import java.io.File
object VisualizePDM extends App {
// Initialize native libraries (important for Scalismo)
scalismo.initialize()
// Create a visualizer UI
val ui = ScalismoUI("PDM Visualizer")
// Create a group in the UI for visualization
val modelGroup = ui.createGroup("pdm")
try {
// Load the PDM from the specified file path
// Replace the path with your actual file path
val loadedPdm = StatisticalModelIO
.readStatisticalPointModel3D(
new File("/home/greg/projects/scalismo_fit/models/humeri_pdm.h5.json")
)
.get
// Display information about the loaded model
println(s"Loaded PDM with ${loadedPdm.rank} principal components")
// Visualize the mean of the PDM
val meanView = ui.show(modelGroup, loadedPdm.mean, "mean")
// Visualize the statistical model
val modelView = ui.show(modelGroup, loadedPdm, "PDM")
println("PDM loaded and visualized successfully")
} catch {
case e: Exception =>
println(s"Error loading or visualizing the PDM: ${e.getMessage}")
e.printStackTrace()
}
}