[Insight-users] ITK in Paraview Plugin

Christian Werner christian.werner at rwth-aachen.de
Mon Mar 1 16:56:55 EST 2010


I am happy to report that a vtkSimpleImageToImageITKFilter gets very 
much smaller when reducing the number of supported Image Data Types.

Actually it becomes as big as about 300K when you only work with one 
image type. Well, in this case you wouldn't need my nifty ImageBox, so 
this was just interesting to see how small the filter can get.

A setup with 2D/3D/uchar, float and double/1 or 3 components (grey or 
RGB) support for example takes 1,2 MB. This is scalable to about 5MB 
which includes all possible variations, leaving out images of one 
dimension. The whole package (including 1D) comes with 7MB. These sizes 
only apply to the filters, the vtkITKImageBox instantiates all 
variations (just in case) and is 9MB big. It is a dynamic library though 
and you only need it once.

I could write some gerenic setups which the user could invoke in his 
filters by calling some appropriate ..._CXX_MACRO

Thank you very much, Luis for your help. One thing would be interesting 
to know: Am I using acceptable coding mechanics to make the compiler 
instantiate all the needed methods? As I said I have never done anything 
like that. In fact that vtk-itk generic filter project was the first 
time I used the word "template" in code...

Best regards,
Christian



Luis Ibanez wrote:
> Hi Christian,
>
> Thanks for sharing the code.
>
> After glancing at it,
> it seems reasonable to expect a size of 9Mb for the library.
>
>
> I was surprised to see that you are instantiating 1-D images.
> ITK indeed supports ND-images, but we usually focus on 2D
> and 3D.
>
>
> Have you identified use cases for 1-D images in ParaView ?
>
>
>     Thanks
>
>
>           Luis
>
>
> ---------------------------------------------------------------------------------------
> On Sat, Feb 27, 2010 at 5:23 AM, Christian Werner
> <christian.werner at rwth-aachen.de> wrote:
>   
>> Hmm, the vtkITKImageBox does contain instantiations for ALL pixel types.
>> This is because I have to make sure that I create a correkt itk ImageType
>> for each vtkImageData input (1-3 Scalar Components, 1-3 Dimensions, 10
>> different Scalar Types). That image box is about 9 MB big, but it is a
>> shared library anyway...
>>
>> The filters who use this box however also include code that checks the
>> vtkImageData and setup an appropriate ImageType. Then they instantiate a
>> corresponding ImageBox<ImageType>. Maybe this way the compiler generates all
>> different kind of class headers for the vtkITKImageBox, but I don't see how
>> this could justify 7MB...
>>
>> Since I am not a professional programmer I don't know much about "Modern C++
>> programming", or generic programming. I had problems with the linker telling
>> me about not finding any reference to specific template functions, because
>> the compiler did not instantiate them. So I just brutally "forced" the
>> compiler to make all instantiations (actually instanitiate each class type
>> and call all its methods explicitly in some dummy code). I think what I am
>> missing here is some understanding about how to do that dynamically... ?
>> On the other hand I have to decide at runtime what ImageType I need for the
>> ITK Filtering because I don't know what vtkImageData I get as input. So this
>> verification has to be implemented in every single filter and the
>> appropriate functions with the corresponding ImageType from the
>> vtkITKImageBox have to exist at this point.
>>
>> If you take a look at my code you will see what I mean. The good thing is
>> that I can use Gaetans Labling/Analysis filtering right out of Paraview now
>> for any kind of image data, and that is what I needed. I actually don't care
>> if it is this big, though I really would have liked to create something more
>> professional. But since this is only a very tiny little part of my work,
>> which already took much more time then planned, I cannot sacrifice more time
>> on that.
>>
>> If you (or maybe somebody else) knows how to improve that, please tell me. I
>> could dive into this again when I have made progress in my actual project
>> and won back some of the time.
>>
>>
>> Best regards,
>> Christian
>>
>>
>>
>>
>> Luis Ibanez wrote:
>>     
>>> Hi Christian,
>>>
>>> Thanks for letting us know.
>>>
>>> The size of the filter seems to be large indeed.
>>>
>>> Does it include instantiations for several different pixel types ?
>>>
>>> As a reference, a typical executable example of ITK is about 300K.
>>> (when using a single pixel type).
>>>
>>> The VolviewPlugins, on the other hand range in size from
>>> 1Mb to 5.3Mb. (They include instantiation for 9 different pixel
>>> types).
>>>
>>> If you run them through "strip" they get about 25% to 30% smaller.
>>> (e.g. a pluging whose shared library was 2.7M gets down to 2.0Mb).
>>>
>>> --
>>>
>>> BTW: You mention some code, I seem to have missed your
>>> email with an attachment, or with instructions on how to download
>>> it.  If the code is available, I will be happy to give it a try.
>>>
>>>
>>>
>>>      Regards,
>>>
>>>
>>>             Luis
>>>
>>>
>>> ---------------------------------------------
>>> On Thu, Feb 25, 2010 at 4:36 PM, Christian Werner
>>> <christian.werner at rwth-aachen.de> wrote:
>>>
>>>       
>>>> It works now when I use TARGET_LINK_LIBRARIES, I just did not do it
>>>> correctly (I did not provide the lib that is actually build!). Strange
>>>> though that the compiler did not seem to care.
>>>>
>>>> There is one issue which is still somewhat annoying. Every Paraview-ITK
>>>> filter is now very big (like 7MB). I do not understand why, but that is
>>>> really huuuuge! I tried reducing this by moving all the exporter/importer
>>>> related code from the ImageBox header into the .cxx code, but that just
>>>> made
>>>> a difference of a view hundred byte.! It didn't work this way either...
>>>>
>>>> This is really strange, I was so happy that I was able to make the
>>>> vtkITKImageBox a shared library and thought that would reduce the size of
>>>> the plugins to "normal" levels. In a VTK-only environment these filters
>>>> get
>>>> as big, by the way.
>>>>
>>>> Maybe if you take a look at the code I sent you, you can make out the
>>>> reason
>>>> for this? I am not sure if the commutiy is glad about being able to
>>>> easily
>>>> use ITK Filters in Paraview-Plugins when they are this big...
>>>>
>>>>
>>>> Best regards,
>>>> Christian
>>>>
>>>>         



More information about the Insight-users mailing list