Skip to content

Instantly share code, notes, and snippets.

@pammacdotnet
Created September 21, 2019 19:57
Show Gist options
  • Save pammacdotnet/31c9d3c530013ad0d5c6736010de296c to your computer and use it in GitHub Desktop.
Save pammacdotnet/31c9d3c530013ad0d5c6736010de296c to your computer and use it in GitHub Desktop.
require 'gvxrRuby'
require 'matplotlib'
Matplotlib.use("TkAgg")
require 'matplotlib/pyplot'
plt = Matplotlib::Pyplot
GvxrRuby.createWindow();
GvxrRuby.setWindowSize(512, 512);
GvxrRuby.setSourcePosition(-40.0, 0.0, 0.0, "cm");
GvxrRuby.usePointSource();
GvxrRuby.setMonoChromatic(0.08, "MeV", 1000);
GvxrRuby.setDetectorPosition(10.0, 0.0, 0.0, "cm");
GvxrRuby.setDetectorUpVector(0, 0, -1);
GvxrRuby.setDetectorNumberOfPixels(640, 320);
GvxrRuby.setDetectorPixelSize(0.5, 0.5, "mm");
GvxrRuby.loadSceneGraph("dragon.stl", "mm");
for i in 0..(GvxrRuby.getNumberOfChildren("root")-1) do
label = GvxrRuby.getChildLabel('root', i) GvxrRuby.moveToCentre(label);
GvxrRuby.setHU(label, 1000);
end
GvxrRuby.disableArtefactFiltering();
x_ray_image = GvxrRuby.computeXRayImage();
plt.imshow(x_ray_image, cmap="gray");
plt.savefig('ruby.png')
GvxrRuby.displayScene();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment