IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
SegmentationTest.cs
1 using UnityEngine;
2 using System.Collections;
3 using itk.simple;
4 
5 public class SegmentationTest : MonoBehaviour {
6  void OnEnable() {
7  PatientEventSystem.startListening (PatientEventSystem.Event.DICOM_NewLoadedVolume, OnDICOMLoaded );
8 
9  DICOMLoader.instance.startLoadingVolume (DICOMLoader.instance.availableSeries [0]);
10  }
11 
12  void OnDisable() {
13  PatientEventSystem.stopListening (PatientEventSystem.Event.DICOM_NewLoadedVolume, OnDICOMLoaded );
14  }
15 
16  public void OnDICOMLoaded( object obj = null )
17  {
18  DICOM2D dicom = obj as DICOM2D;
19  if (dicom == null)
20  return;
21  if (dicom.dimensions != 3)
22  return;
23 
24  Image volume = dicom.image;
25  Debug.Log ("Width: " + volume.GetWidth () + ", height: " + volume.GetHeight () + ", depth: " + volume.GetDepth ());
26 
27  VectorUInt32 position = new VectorUInt32 {
28  volume.GetWidth() / 2,
29  volume.GetHeight() / 2,
30  volume.GetDepth() / 2
31  };
32  // Asumes that the pixel type stored in the image is grayscale int32:
33  int value = volume.GetPixelAsInt16 (position);
34  Debug.Log ("Value of center pixel: " + value);
35  }
36 }
int dimensions
Definition: DICOM.cs:18