[ITK] CREATE 3D VOLUME

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Dec 17 09:16:17 EST 2015


Hello Selwyn,

It sounds like you have an exciting project.

SimpleITK’s interface is a little different that native ITK.

1) There are no “New” methods in SimpleITK. ITK’s is written for C++ and uses smart pointers with the “New” method for memory allocations. On the other hand SimpleITK was designed for scripting languages where memory allocation and management happens automatically with in the language  [1].

2) SimpleITK’s filters have an Execute(input1, input2, etc..) method instead of ITK’s pipeline with methods like SetInput, Update, Disconnect, etc… SimpleITK’s uses the “Execute" method for immediate execution which provide a simpler  and some time more efficient execution model for image processing.

3) You may want to run through some of the SimpleITK Python Notebooks [2] for a tutorial. It will be well work the time to setup your Python environment to include Notebooks, so that you can interact with the Python interpreter command by command, and get inline help.

HTH,
Brad


[1] https://en.wikipedia.org/wiki/Memory_management
[2] https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks

> On Dec 16, 2015, at 10:37 PM, Selwyn Hector via Community <community at itk.org> wrote:
> 
> Dear ITK Community,
> 
> I am high school senior extremely interested in programming and dedicated my graduating senior project to a SimpleITK program. I have basic understanding of computer science with skills in both python and Java. 
> 
> I am basically trying to rewrite an ITK example,Create 3D Volume <http://itk.org/ITKExamples/src/Filtering/ImageGrid/Create3DVolume/Documentation.html#create-3d-volume>, into a SimpleITK program. Create 3D volume uses the TileImageFilter and DisconnectPipeline methods in order to merge multiple two dimensional images into a three dimensional image. If I follow the example on the site and use InputImageType as a parameter of InputImageType then I receive the error "wrong number or type of  argument for overloaded function new_Image". I looked up the function .Image and rewrote the program in a way that fits all parameters. The program is below:
> 
> from __future__ import print_function
> 
> import SimpleITK as sitk
> import sys
> import os
> import numpy
> import matplotlib as plt
> 
> if len(sys.argv) != 3:
>     print("Usage: " + sys.argv[0] + "<python.png> <prediction.png> <output.png>")
>     sys.exit(1)
> 
> InputDimension = 2
> OutputDimension = 3
> 
> pixelType = sitk.sitkFloat32
> TInputImage = sitk.Image(32, 32, InputDimension)
> TOutputImage = sitk.Image(32, 32, OutputDimension)
> 
> reader = sitk.ImageFileReader()
> 
> tileFilter = sitk.TileImageFilter()
>     
> layout = [2, 2, 0]
> defaultvalue = 128
> 
> tileFilter.SetLayout(layout)
> 
> for ii in range(1, len(sys.argv)-1):
>     reader.SetFileName(sys.argv[ii])
>     reader.Update()
> 
>     inputImage = sys.reader.GetOutput()
>     inputImage.DisconnectPipeline()
> 
>     tileFilter.SetInput(ii-1, inputImage)
> 
> tileFilter.SetDefaultPixelValue(defaultvalue)
> tileFilter.Update()
> 
> writer = sitk.ImageFileWriter(TOutputImage).New()
> writer.SetFileName(sys.argv[-1])
> writer.SetInput(TileFitler.GetOutput())
> writer.Update()
> 
> This program is also based on the example but I doWhen i run this program through the command prompt along with images I am trying to import I receive the error "AttributeError; type object 'object' has no attribute '__getattr__'.
> 
> I would love to complete this program and begin to work on future personal ITK projects so I would appreciate help on this. Please let me know If I have made any formatting mistakes or reached out in the wrong way. Thank you all so much!
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20151217/4c0b8ad8/attachment.html>


More information about the Community mailing list