[Insight-users] Flexible Vector Image class - ImageToListAdaptor

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Nov 23 11:46:04 EST 2005


Dr. Uwe Köhler wrote:

>Dear Karthik,
>
>many thanks for your quick reply. I will post the solution to the list and 
>send you code for the very useful test file.
>
>The declaration of 
> 
>    typedef itk::Statistics::ListSample< VectorImagePixelType > 
>	VariableLengthListSampleType;
>    VariableLengthListSampleType::Pointer sampleList = 
>	VariableLengthListSampleType::New();
> essentially  itk::ListSample< VariableLengthVector< float > >
>
>just shifts the problem to 
>/usr/local/include/InsightToolkit/Numerics/Statistics/itkSample.h: In member
>   function `void
>   itk::Statistics::Sample<TMeasurementVector>::SetMeasurementVectorSize(unsigned
>   int) [with TMeasurementVector = VectorImagePixelType]':
>/usr/local/include/InsightToolkit/Common/itkImageRegionConstIterator.txx:93:   
>instantiated from here
>/usr/local/include/InsightToolkit/Numerics/Statistics/itkSample.h:116: error: 
>no
>   matching function for call to `itk::MeasurementVectorTraits::GetLength(
>   VectorImagePixelType&)'
>
>I fail to see the point where SetMeasurementVectorSize is called in the 
>constructor, but ...
>itkSample.h puts m_MeasurementVectorSize = 0; ListSampleBase() {};
>template< class TMeasurementVector >
>ListSample< TMeasurementVector >
>::ListSample()
>{
>}
>
>  
>
Thanks. Please update your CVS repository and the build errors should go 
away.

I just added definitions to
Code/Numerics/Statistics/itkMeasurementVectorTraits.h

>Anyway, I believe the best solution it to provide either Length or GetLength 
>for VariableLengthVector where it is called Size?
>
>  
>
The solution is a little deeper than that. In ITK version 2.0, most of 
the statistics framework was written assuming that you knew the number 
of random variates at compile time ( so it could be a template parameter 
).  [ Just to clarify,  the number of random variates is different from 
the number of samples. For instance, a Joint Intensity histogram of two 
images would have 2 random variates and as many samples as the number of 
pixels in the image. ] . This was a reasonable assumption since it was 
assumed when working with images you know the number of random variates 
before hand.

That being assumed, Statistics in ITK 2.0 used itk::Vector< datatype, 
Length > as the measurement vector.

Later people started doing things like classification/segmentation 
etc... where they wanted the number of classes to be specified at run 
time and then compute joint statistics etc on them. That needed the 
Vector to change to VariableLengthVector with the length specified at 
run time, This was one of the changes in ITK 2.2

However there are one or two classes like the ImageToListAdaptor which 
weren't transitioned to have the ability to specify the number of random 
variates at run time. Give me a few days and I will fix that.

>Well, I just do not have the overview you have. A student of mine is working 
>on the 2 GB problem and he will be back next week. He traced it down in 
>Visual C++. I tried libEfence in Linux and did not find memory leaks for 
>Get().
>
>Many thanks again
>
>Uwe
>
>Am Dienstag, 22. November 2005 21:18 schrieben Sie:
>  
>
>>ImageToListAdaptor will work only on pixeltypes where the length is
>>known before hand.
>>
>>For instance ImageToListAdaptor will work on
>>Image< FixedArray< float, 10 > , 3 >
>>but not
>>Image< VariableLengthVector< float > , 3 >
>>or
>>VectorImage< float, 3 >
>>
>>Your best bet is to write a function that creates the list using the
>>interfaces provided in ListSample.
>>If you are using ITK 2.2 and above, you should be able to instantiate a
>>itk::ListSample< VariableLengthVector< float > > and manually fill it
>>using the Get() inteface on the ImageIterator and PushBack() interface
>>from the list.
>>
>>of course, this will not be an adaptor..
>>
>>thanks
>>karthik
>>
>>    
>>
>
>  
>


More information about the Insight-users mailing list