hi Gaëtan, it works again:). But i got two new questions:)<br><br> transformer = itk.TranslationTransform[itk.D, 2].New()<br> optimizer = itk.RegularStepGradientDescentOptimizer.New()<br> interpolator = itk.LinearInterpolateImageFunction[itk.Image.US2, itk.D].New()<br>
metric = itk.MeanSquaresImageToImageMetric[itk.Image.US2,itk.Image.US2].New()<br> registration_object = itk.ImageRegistrationMethod[itk.Image.US2,itk.Image.US2].New()<br> registration_object.SetMetric(metric.GetPointer())<br>
registration_object.SetOptimizer(optimizer.GetPointer())<br> registration_object.SetTransform(transformer.GetPointer())<br> registration_object.SetInterpolator(interpolator.GetPointer())<br> registration_object.SetFixedImage(convertor.GetOutput())<br>
registration_object.SetMovingImage(convertor1.GetOutput())<br> registration_object.SetFixedImageRegion(convertor.GetOutput().GetBufferedRegion())<br><br> #parameters = itk.RegistrationType.ParametersType(transformer.GetNumberOfParameters())<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~this failed in the python, what should i do to construct a ParametersType object in python?<br><br> parameters = [0.0, 0.0]<br> ~~~~~~~~~~~~~~~~~just treat parameters as a list seems works, am i correct?<br>
<br> registration_object.SetInitialTransformParameters(parameters)<br> optimizer.SetMaximumStepLength(4.00)<br> optimizer.SetMinimumStepLength(0.01)<br> optimizer.SetNumberOfIterations(200)<br>
<br> try:<br> registration_object.Update()<br> except itkError:<br> print itkError<br><br> last_para = registration_object.GetLastTransformParameters()<br> ~~~~~~~this returns a itkArray pointer and it seems unindexable, cause it failed when i using "last_para[0]" how can i access the actual transform parameters? thanks in advance again;)<br>
<br>Regards,<br><br>Alex<br><br><div class="gmail_quote">2009/11/18 Gaëtan Lehmann <span dir="ltr"><<a href="mailto:gaetan.lehmann@jouy.inra.fr">gaetan.lehmann@jouy.inra.fr</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Le 18 nov. 09 à 14:17, alex sando a écrit :<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Great! It works! thank you Gaëtan :)<br>
<br>
But i got an error when i tried to use ITK python to finish some Registration work....Here is my code:<br>
<br>
transformer = itk.TranslationTransform[itk.D, 3].New()<br>
optimizer = itk.RegularStepGradientDescentOptimizer.New()<br>
interpolator = itk.LinearInterpolateImageFunction[itk.Image.US3, itk.D].New()<br>
metric = itk.MeanSquaresImageToImageMetric[itk.Image.US3,itk.Image.US3].New()<br>
registration_object = itk.ImageRegistrationMethod[itk.Image.US3,itk.Image.US3].New()<br>
registration_object.SetMetric(metric)<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~ I got an error from this<br>
TypeError: Type error. Got _p_itk__SmartPointerTitk__MeanSquaresImageToImageMetricTitk__ImageTunsigned_short_3u_t_itk__ImageTunsigned_short_3u_t_t_t, expected _p_itk__SmartPointerTitk__ImageToImageMetricTitk__ImageTunsigned_short_3u_t_itk__ImageTunsigned_short_3u_t_t_t<br>
<br>
Is there something i do wrong when invorking the method? The error may indicate the SetMetric function requires a base class... could you tell how to solve it.... many many thanks<br>
<br>
</blockquote>
<br></div>
Usually, when a base class is requested, you have to pass a raw pointer instead of a smart pointer. You can get it with the method GetPointer()<br>
<br>
registration_object.SetMetric(metric.GetPointer())<br>
<br>
may work.<div><div></div><div class="h5"><br>
<br>
Gaëtan<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Alex<br>
<br>
<br>
<br>
2009/11/18 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>><br>
<br>
Le 18 nov. 09 à 09:30, alex sando a écrit :<br>
<br>
<br>
hi Gaëtan, my wrapITK is installed in:<br>
<br>
C:\Program Files\WrapITK<br>
<br>
itkvtkGlue is installed in:<br>
<br>
C:\Program Files\ItkVtkGlue<br>
<br>
Do you mean that i should copy ItkVtkGlue into the WrapITK directory?<br>
<br>
<br>
I was thinking to change the base path in CMAKE_INSTALL_PREFIX with cmake gui, and to rebuild and reinstall ItkVtkGlue.<br>
<br>
<br>
<br>
Regards,<br>
<br>
Alex<br>
<br>
<br>
2009/11/18 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>><br>
<br>
Le 18 nov. 09 à 09:11, alex sando a écrit :<br>
<br>
<br>
Thanks Gaëtan, I built itkvtkglue project successfully:<br>
<br>
1>------ Build started: Project: INSTALL, Configuration: Release Win32 ------<br>
1><br>
1>Performing Post-Build Event...<br>
1>-- Install configuration: "Release"<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/include/InsightToolkit/BasicFilters/itkImageToVTKImageFilter.h<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/include/InsightToolkit/BasicFilters/itkImageToVTKImageFilter.txx<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/include/InsightToolkit/BasicFilters/itkVTKImageToImageFilter.h<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/include/InsightToolkit/BasicFilters/itkVTKImageToImageFilter.txx<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/ClassIndex/ItkVtkGlue.mdx<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/lib/_ItkVtkGluePython.pyd<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/ClassIndex/wrap_ItkVtkGluePython.idx<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/lib/ItkVtkGluePython.py<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/ClassIndex/wrap_itkImageToVTKImageFilter.idx<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/lib/itkImageToVTKImageFilter.py<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/ClassIndex/wrap_itkVTKImageToImageFilter.idx<br>
1>-- Installing: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/lib/itkVTKImageToImageFilter.py<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/SWIG/ItkVtkGlue.swg<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/Python/Configuration/ItkVtkGlueConfig.py<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/Python/ItkVtkGlue.py<br>
1>-- Installing external project into the WrapITK installation directory.<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/Python/itkvtk.py<br>
1>-- Up-to-date: C:/Program Files/ItkVtkGlue/lib/InsightToolkit/WrapITK/Python/itkExtras/itkvtkExtras.py<br>
1>Build log was saved at "file://d:\ITKVTKBuild\INSTALL.dir\Release\BuildLog.htm"<br>
1>INSTALL - 0 error(s), 0 warning(s)<br>
========== Build: 1 succeeded, 0 failed, 4 up-to-date, 0 skipped ==========<br>
<br>
But i still get error message when import the module:<br>
<br>
import ItkvtkGlue<br>
ImportError: No module named ItkvtkGlue<br>
or<br>
import itkvtk<br>
ImportError: No module named itkvtk<br>
<br>
So I guess VTKImageToImageFilter may be built into the itk module, so i try the filter directly in the source code without the extra "import" expressions:<br>
<br>
print "Start to OpenFile"<br>
convertor = itk.VTKImageToImageFilter[itk.Image.US3].New(imageData)<br>
img = convertor.GetOutput()<br>
convertor.Update();<br>
print "Finished OpenFile"<br>
<br>
, but only get:<br>
<br>
AttributeError: 'LazyITKModule' object has no attribute 'VTKImageToImageFilter'<br>
<br>
How can i fix this.... many many thanks for suggestions...<br>
<br>
Hi Alex,<br>
<br>
The base path for the installation must be the same than the one used for WrapITK. I don't think that WrapITK is installed in C:/Program Files/ItkVtkGlue.<br>
Can you try to install ItkVtkGlue in the same dir than WrapITK?<br>
<br>
Gaëtan<br>
<br>
<br>
<br>
<br>
Alex<br>
<br>
<br>
2009/11/18 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>><br>
<br>
Le 17 nov. 09 à 07:59, alex sando a écrit :<br>
<br>
<br>
hi, currently i want to import a vtkImageData to itkImage so that the data could be processed using some ITK filters, but when i execute the following code:<br>
<br>
imageData = reader.GetOutput()<br>
print "Start to OpenFile"<br>
convertor = itk.VTKImageToImageFilter[itk.Image.S3].New(imageData)<br>
img = convertor.GetOutput()<br>
convertor.Update();<br>
print "Finished OpenFile"<br>
<br>
always get the following error message:<br>
File "D:\Lab Affairs\src\control\Common.py", line 448, in _simpleProcess<br>
convertor = itk.VTKImageToImageFilter[...].New(imageData)<br>
File "C:\Program Files\WrapITK\lib\InsightToolkit\WrapITK\Python\itkLazy.py", line 14, in __getattribute__<br>
value = types.ModuleType.__getattribute__(self, attr)<br>
AttributeError: 'LazyITKModule' object has no attribute 'VTKImageToImageFilter'<br>
<br>
VTKImageToImageFilter is not wrapped in the WrapITK? how can i convert the image from & to between vtkImageData and itkImage? thanks...<br>
<br>
It is in WrapITK, but in an external project.<br>
See Wrapping/WrapITK/ExternalProjects/ItkVtkGlue<br>
<br>
Gaëtan<br>
<br>
<br>
<br>
Regards,<br>
<br>
Alex<br>
<br>
On Tue, Nov 17, 2009 at 1:20 PM, alex sando <<a href="mailto:yejun.alex@gmail.com" target="_blank">yejun.alex@gmail.com</a>> wrote:<br>
Thanks Gaëtan! It seems work well on my platform:). Some little issues i encountered in the progress, just a record for later's reference :).<br>
1. _BasePython project in WrapITK failed because /bigobj compile flag is not set defaultly.<br>
2. Dont forget to add path which contains SwigRuntimePython.dll to PATH<br>
<br>
Regards,<br>
<br>
Alex<br>
<br>
2009/11/17 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>><br>
<br>
<br>
Le 16 nov. 09 à 19:14, alex sando a écrit :<br>
<br>
<br>
hello Gaëtan<br>
<br>
Currently i use itk 3.14 and Cableswig 3.14 and wrapitk0.2 in the source of itk 3.14. But when i build wrapitk, it failed with a lot of "itkFlatStructuringElement.h: No such file or directory" error.... can you give me any suggestion to solve this? many thanks, my platform is xp with vs2005 and cmake 2.8.<br>
<br>
Sure: turning on ITK_USE_REVIEW in cmake gui should help.<br>
Please let me know if that fix your problem.<br>
<br>
Regards,<br>
<br>
Gaëtan<br>
<br>
<br>
<br>
<br>
Regards,<br>
<br>
Alex<br>
<br>
2009/11/16 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr" target="_blank">gaetan.lehmann@jouy.inra.fr</a>><br>
<br>
Le 16 nov. 09 à 13:32, alex sando a écrit :<br>
<br>
<br>
hi all,<br>
I am currently working on an legacy system which is composed under python 2.3. Is there any method that could help me to create the itk python wrap under python 2.3? I search for a while on the internet and find the wrapitk is a great tool for using itk under python environment, but its requirement for the version of python is at least 2.4...I also tried to compile the wrap using cmake, but failed with<br>
<br>
<br>
CMake Warning at CMakeLists.txt:173 (FIND_PACKAGE):<br>
Could not find module FindCableSwig.cmake or a configuration file for<br>
package CableSwig.<br>
Adjust CMAKE_MODULE_PATH to find FindCableSwig.cmake or set CableSwig_DIR<br>
to the directory containing a CMake configuration file for CableSwig. The<br>
file will have one of the following names:<br>
CableSwigConfig.cmake<br>
cableswig-config.cmake<br>
CMake Error at CMakeLists.txt:185 (MESSAGE):<br>
CableSwig is required for CSwig Wrapping.<br>
Configuring incomplete, errors occurred!<br>
<br>
But in fact i set the CableSwig_DIR directory correctly... Is there any suggestion to get itk work under python 2.3.....great appreciate....<br>
<br>
<br>
Hi Alex,<br>
<br>
I think that WrapITK 0.2 - in ITK sources - *should* work with python 2.3.<br>
<br>
Can you give more informations on your system? OS, cmake version, compiler, ITK version, CableSwig version, …<br>
<br>
<br>
Regards,<br>
<br>
Gaëtan<br>
<br>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
<br>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
<br>
<br>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
<br>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
<br>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
<br>
</blockquote>
<br>
-- <br>
Gaëtan Lehmann<br>
Biologie du Développement et de la Reproduction<br>
INRA de Jouy-en-Josas (France)<br>
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09<br>
<a href="http://voxel.jouy.inra.fr" target="_blank">http://voxel.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
<a href="http://www.mandriva.org" target="_blank">http://www.mandriva.org</a> <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
<br>
</div></div></blockquote></div><br>