SimpleITK  1.3.0.dev466
ImageViewing/ImageViewing.py
1 #=========================================================================
2 #
3 # Copyright Insight Software Consortium
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0.txt
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 #=========================================================================
18 
19 import sys
20 import SimpleITK as sitk
21 
22 
23 grid_image = sitk.GridSource(outputPixelType=sitk.sitkUInt16, size=(512,512),
24  sigma=(0.1,0.1), gridSpacing=(20.0,20.0))
25 
26 # Procedural interface, using the default image viewer (Fiji/ImageJ) or
27 # any viewer specified by the SITK_SHOW_COMMAND environment variable.
28 sitk.Show(grid_image, title = "grid using Show function", debugOn = True)
29 
30 # Object oriented interface:
31 image_viewer = sitk.ImageViewer()
32 image_viewer.SetTitle('grid using ImageViewer class')
33 
34 # Use the default image viewer.
35 image_viewer.Execute(grid_image)
36 
37 # Change viewer, and display again.
38 image_viewer.SetApplication('/Applications/ITK-SNAP.app/Contents/MacOS/ITK-SNAP')
39 image_viewer.Execute(grid_image)
40 
41 # Change the viewer command, (use ITK-SNAP's -z option to open the image in zoomed mode)
42 image_viewer.SetCommand('/Applications/ITK-SNAP.app/Contents/MacOS/ITK-SNAP -z 2')
43 image_viewer.Execute(grid_image)
44 
45 sys.exit( 0 )