This file is indexed.

/usr/share/vtk/ImageProcessing/Tcl/ImageSlicing.tcl is in vtk-examples 5.8.0-17.5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package require vtk
package require vtkinteraction

# This example shows how to load a 3D image into VTK and then reformat
# that image into a different orientation for viewing.  It uses
# vtkImageReslice for reformatting the image, and uses vtkImageActor
# and vtkInteractorStyleImage to display the image.  This InteractorStyle
# forces the camera to stay perpendicular to the XY plane.

# Start by loading some data.
vtkImageReader2 reader
  reader SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"
  reader SetDataExtent 0 63 0 63 1 93
  reader SetDataSpacing 3.2 3.2 1.5
  reader SetDataOrigin 0.0 0.0 0.0
  reader SetDataScalarTypeToUnsignedShort
  reader UpdateWholeExtent

# Calculate the center of the volume
[reader GetOutput] UpdateInformation
set extent [[reader GetOutput] GetWholeExtent]
set spacing [[reader GetOutput] GetSpacing]
set origin [[reader GetOutput] GetOrigin]

set xMin [lindex $extent 0]
set xMax [lindex $extent 1]
set yMin [lindex $extent 2]
set yMax [lindex $extent 3]
set zMin [lindex $extent 4]
set zMax [lindex $extent 5]

set xSpacing [lindex $spacing 0]
set ySpacing [lindex $spacing 1]
set zSpacing [lindex $spacing 2]

set x0 [lindex $origin 0]
set y0 [lindex $origin 1]
set z0 [lindex $origin 2]

set xCenter [expr $x0 + $xSpacing * 0.5 * ($xMin + $xMax)]
set yCenter [expr $y0 + $ySpacing * 0.5 * ($yMin + $yMax)]
set zCenter [expr $z0 + $zSpacing * 0.5 * ($zMin + $zMax)]

# Matrices for axial, coronal, sagittal, oblique view orientations
vtkMatrix4x4 axial
set elements { 1  0  0  $xCenter
               0  1  0  $yCenter
               0  0  1  $zCenter
               0  0  0  1}
for {set i 0} {$i < 16} {incr i} {
  axial SetElement [expr $i / 4] [expr $i % 4] [expr [lindex $elements $i]] 
}

vtkMatrix4x4 coronal
set elements { 1  0  0  $xCenter
               0  0  1  $yCenter
               0 -1  0  $zCenter
               0  0  0  1}
for {set i 0} {$i < 16} {incr i} {
  coronal SetElement [expr $i / 4] [expr $i % 4] [expr [lindex $elements $i]] 
}

vtkMatrix4x4 sagittal
set elements { 0  0 -1  $xCenter
               1  0  0  $yCenter
               0 -1  0  $zCenter
               0  0  0  1}
for {set i 0} {$i < 16} {incr i} {
  sagittal SetElement [expr $i / 4] [expr $i % 4] [expr [lindex $elements $i]] 
}


vtkMatrix4x4 oblique
set elements { 1  0  0  $xCenter
               0  0.866025 -0.5  $yCenter
               0  0.5  0.866025  $zCenter
               0  0  0  1 }
for {set i 0} {$i < 16} {incr i} {
  oblique SetElement [expr $i / 4] [expr $i % 4] [expr [lindex $elements $i]] 
}

# Extract a slice in the desired orientation
vtkImageReslice reslice
  reslice SetInputConnection [reader GetOutputPort]
  reslice SetOutputDimensionality 2 
  reslice SetResliceAxes sagittal 
  reslice SetInterpolationModeToLinear

# Create a greyscale lookup table
vtkLookupTable table
  table SetTableRange 0 2000 
  table SetValueRange 0.0 1.0
  table SetSaturationRange 0.0 0.0
  table SetRampToLinear
  table Build

# Map the image through the lookup table
vtkImageMapToColors color
  color SetLookupTable table
  color SetInputConnection [reslice GetOutputPort]

# Display the image
vtkImageActor actor
  actor SetInput [color GetOutput]

vtkRenderer renderer
  renderer AddActor actor

vtkRenderWindow window
  window AddRenderer renderer

# Set up the interaction
vtkInteractorStyleImage imageStyle

vtkRenderWindowInteractor interactor
  interactor SetInteractorStyle imageStyle
  window SetInteractor interactor 
  window Render

# Create callbacks for slicing the image
global action
set action ""

proc ButtonPressCallback {} {
    global action
    set action "Slicing"
}

proc ButtonReleaseCallback {} {
    global action
    set action ""
}

proc MouseMoveCallback {} {
    set lastPos [interactor GetLastEventPosition]
    set currPos [interactor GetEventPosition]
    global action
    if {$action == "Slicing"} {
        set deltaY [expr [lindex $currPos 1] - [lindex $lastPos 1]]
        [reslice GetOutput] UpdateInformation
        set spacing [[reslice GetOutput] GetSpacing]
        set sliceSpacing [lindex $spacing 2]
        set matrix [reslice GetResliceAxes]
        # move the center point that we are slicing through
        set center [$matrix MultiplyPoint 0 0 [expr $sliceSpacing * $deltaY] 1]
        $matrix SetElement 0 3 [lindex $center 0]
        $matrix SetElement 1 3 [lindex $center 1]
        $matrix SetElement 2 3 [lindex $center 2]
        window Render
    } else {
        imageStyle OnMouseMove
    }
}

imageStyle AddObserver MouseMoveEvent MouseMoveCallback
imageStyle AddObserver LeftButtonPressEvent ButtonPressCallback
imageStyle AddObserver LeftButtonReleaseEvent ButtonReleaseCallback

interactor AddObserver UserEvent {wm deiconify .vtkInteract}
interactor AddObserver ExitEvent {exit}
interactor Initialize

#
# Hide the default . widget
#
wm withdraw .

#
# You only need this line if you run this script from a Tcl shell
# (tclsh) instead of a Tk shell (wish)
#
tkwait window .