Exemplo n.º 1
0
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#==========================================================================*/

#
#  Example on the use of the MedianImageFilter
#

import itk
from sys import argv

input_filename = argv[1]
output_filename = argv[2]
radius = int(argv[3])

reader = itk.ImageFileReader.IUC2.New(FileName=input_filename)

# test the deduction of the template parameter from the input
filt = itk.MedianImageFilter.New(reader, Radius=radius)
filt.Update()
result = filt.GetOutput()
watcher = itk.XMLFilterWatcher(filt, "filter")

# test the update of the filter with the snake case function
# and the setting of parameter inside it
result = itk.median_image_filter(reader, radius=radius)

# test the write method
itk.imwrite(result, output_filename)
Exemplo n.º 2
0
#
#  Example on the use of the MedianImageFilter
#

import itk
from sys import argv

dim = 2
IType = itk.Image[itk.US, dim]
OIType = itk.Image[itk.UC, dim]

reader = itk.ImageFileReader[IType].New( FileName=argv[1] )
filter  = itk.MedianImageFilter[IType, IType].New( reader, Radius=eval( argv[3] ) )

watcher = itk.XMLFilterWatcher( filter.GetPointer(), "filter" )

cast = itk.CastImageFilter[IType, OIType].New(filter)
writer = itk.ImageFileWriter[OIType].New( cast, FileName=argv[2] )

writer.Update()