File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData' ;
2
+ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray' ;
3
+
4
+ /**
5
+ * Converts an itk.js image to a vtk.js image.
6
+ *
7
+ * Requires an itk.js image as input.
8
+ */
9
+ function convertItkToVtkImage ( itkImage ) {
10
+ // create VTK image data
11
+ const imageData = vtkImageData . newInstance ( {
12
+ origin : itkImage . origin . slice ( ) ,
13
+ spacing : itkImage . spacing . slice ( ) ,
14
+ } ) ;
15
+ const scalars = vtkDataArray . newInstance ( {
16
+ name : 'Scalars' ,
17
+ values : itkImage . data ,
18
+ numberOfComponents : itkImage . imageType . components ,
19
+ } ) ;
20
+
21
+ imageData . setDirection ( itkImage . direction . data ) ;
22
+ imageData . setDimensions ( ...itkImage . size ) ;
23
+ imageData . getPointData ( ) . setScalars ( scalars ) ;
24
+
25
+ return imageData ;
26
+ }
27
+
28
+ export default {
29
+ convertItkToVtkImage,
30
+ } ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import vtkCone from './Cone';
5
5
import vtkCylinder from './Cylinder' ;
6
6
import vtkDataSet from './DataSet' ;
7
7
import vtkDataSetAttributes from './DataSetAttributes' ;
8
+ import vtkITKHelper from './ITKHelper' ;
8
9
import vtkImageData from './ImageData' ;
9
10
import vtkImplicitBoolean from './ImplicitBoolean' ;
10
11
import vtkLine from './Line' ;
@@ -25,6 +26,7 @@ export default {
25
26
vtkCylinder,
26
27
vtkDataSet,
27
28
vtkDataSetAttributes,
29
+ vtkITKHelper,
28
30
vtkImageData,
29
31
vtkImplicitBoolean,
30
32
vtkLine,
You can’t perform that action at this time.
0 commit comments