[Insight-users] CovarianceCalculator

Luis Ibanez luis.ibanez at kitware.com
Sat Jun 19 11:06:30 EDT 2004


Hi Lucas,

Thanks for your clarifications,

1) This sounds like a reasonable thing to try.
    Note that most of the classes in the Statistic
    framework are templated over the vector type.

    It is then likely that you could instantiate
    them over a std::vector, or any other container
    providing the "operator[]" for element access.

    Please let us know if you encounter any problems
    with those instantiations.


2) If you want to write your own ImageIO class, you
    are strongly encouraged to read the I/O chapter
    in the software guide:

       http://www.itk.org/ItkSoftwareGuide.pdf

    Chapter 7, pdf-page 219.

    For an example, you may want to look at one of
    the simplest ImageIO classes in ITK: BMPImageIO


             Insight/Code/IO/
                          itkBMPImageIO




   Regards,


     Luis



----------------------
Lucas Lorenzo wrote:

> Hi Luis,
> 
> thanks again.
> 
> 1) the processing that I plan to do on it is:
> a) to pass individual pixels (vectors) as arguments for the 
> MahalanobisDistanceMembershipFunction class;
> b) to pass a sample list of pixels (vectors) as an argument for theMean 
> Calculator class;
> c) to pass a sample list of pixels (vectors) as an argument for the 
> CovarianceCalculator class.
> 
> 2) Let's say that I'm going to write my own ImageIO object. Is there any 
> documentation and/or example I could use ?
> 
> Thanks,
> 
> Lucas
> 
> 
> On Jun 16, 2004, at 1:43 PM, Luis Ibanez wrote:
> 
> 
>     Hi Lucas,
> 
>     If the vector size is not known at compliation time,
>     you are probably having to defined the images as:
> 
>     itk::Image< std::vector< float >, Dimension >
> 
>     and.. in that case you will have to write your own
>     ImageIO object in order to read the fileformat.
> 
> 
>     Another option for you could be to store individual
>     components per file. That is, instead of a file with
>     and image with 60 components per pixel, you could
>     store 60 files each one with an image of 1 component
>     per pixel.
> 
>     You could read these images sequencially using any
>     of the existing fileformats, an then copy the content
>     fron the incoming image into the i-th component of
>     the
> 
>     itk::Image< std::vector< float >, Dimension >
> 
>     You may want to sit in a peaceful place with some
>     coffee and do the math for the memory footprint of
>     such an image, because it can easily get out of control.
> 
>     Note also that you must consider upfront the type
>     of processing that you expect to apply to such an
>     image.
> 
>     Are you planning to do segmentation on it ?
>     maybe statistical classification ?
> 
> 
>     Note that the above image type may not satisfy the
>     API expected by some ITK filters.
> 
> 
> 
>     Regards,
> 
> 
>     Luis
> 
> 
> 
>     --------------------
>     Lucas Lorenzo wrote:
> 
>         Hi Luis,
>         thanks a lot for your answer.
>         mmm ... my problem is that I'll have to deal with 2D images of
>         vectors (right now I've defined them as itk::Vector type) but
>         the length of these vectors might change from one file to another.
>         Is there any way to load such an image from a file without
>         knowing the vector size at compilation time ?
>         Thanks,
>         Lucas
>         On Jun 15, 2004, at 11:31 PM, Luis Ibanez wrote:
> 
> 
>             Hi Lucas,
> 
>             The source of the problem is that VXL uses explicit
>             instantiation of Templates as opposed to ITK that
>             uses implicit instatiation.
> 
>             This means that in vnl you can only use types that
>             have already been explicity instantiated in the
>             library. If you need to use a new combination, then
>             you have to add the corresponding explicit instantiation.
> 
>             The vnl_fixed_matrix is only instantiated for a
>             certain number of template parameters.
> 
>             You will find them under:
> 
>             Insight/Utilities/vxl/core/vnl/Templates
> 
>             They are
> 
>             vnl_matrix_fixed+double.1.1-.cxx
>             vnl_matrix_fixed+double.1.2-.cxx
>             vnl_matrix_fixed+double.1.3-.cxx
>             vnl_matrix_fixed+double.2.1-.cxx
>             vnl_matrix_fixed+double.2.2-.cxx
>             vnl_matrix_fixed+double.2.3-.cxx
>             vnl_matrix_fixed+double.2.4-.cxx
>             vnl_matrix_fixed+double.2.6-.cxx
>             vnl_matrix_fixed+double.3.1-.cxx
>             vnl_matrix_fixed+double.3.2-.cxx
>             vnl_matrix_fixed+double.3.3-.cxx
>             vnl_matrix_fixed+double.3.4-.cxx
>             vnl_matrix_fixed+double.3.5-.cxx
>             vnl_matrix_fixed+double.4.1-.cxx
>             vnl_matrix_fixed+double.4.2-.cxx
>             vnl_matrix_fixed+double.4.3-.cxx
>             vnl_matrix_fixed+double.4.4-.cxx
>             vnl_matrix_fixed+double.6.6-.cxx
>             vnl_matrix_fixed+float.1.2-.cxx
>             vnl_matrix_fixed+float.1.3-.cxx
>             vnl_matrix_fixed+float.2.1-.cxx
>             vnl_matrix_fixed+float.2.2-.cxx
>             vnl_matrix_fixed+float.3.1-.cxx
>             vnl_matrix_fixed+float.3.3-.cxx
>             vnl_matrix_fixed+float.3.4-.cxx
>             vnl_matrix_fixed+float.3.5-.cxx
>             vnl_matrix_fixed+float.4.3-.cxx
>             vnl_matrix_fixed+float.4.4-.cxx
>             vnl_matrix_fixed+int.2.2-.cxx
>             vnl_matrix_fixed+int.3.4-.cxx
>             vnl_matrix_fixed+vnl_bignum.3.3-.cxx
>             vnl_matrix_fixed+vnl_rational.3.3-.cxx
>             vnl_matrix_fixed_pairwise_ops.cxx
>             vnl_matrix_fixed_ref+double.3.3-.cxx
>             vnl_matrix_fixed_ref+double.3.4-.cxx
>             vnl_matrix_fixed_ref+float.3.3-.cxx
>             vnl_matrix_fixed_ref+float.3.4-.cxx
> 
> 
>             As you can see, there is no instantiation for a matrix
>             of size 60 x 60 which is what you seems to be trying
>             to instantiate.
> 
>             BTW, Do you realy have a problem where your
>             feature vector has 60 components ?
> 
> 
>             If you really want to have 60 x 60 for
>             the matrix dimension, then you could add
>             a new file for explicit instantiation of
>             your matrix type. Note that you must add
>             this new file to the CMakeLists.txt file
>             in that directory.
> 
>             You may want to take a file such as:
> 
>             vnl_matrix_fixed+double.6.6-.cxx
> 
>             and copy/rename it as
> 
>             vnl_matrix_fixed+double.60.60-.cxx
> 
>             and change its internals in order to
>             use 60 x 60 as template arguments for
>             the matrix dimensions.
> 
> 
> 
> 
>             Regards,
> 
> 
>             Luis
> 
> 
> 
>             ---------------------
>             Lucas Lorenzo wrote:
> 
>                 Hi all,
>                 I'm having a linking problem when compiling the
>                 following code (I'm including only the important parts):
>                 /
>                 #include "itkVector.h"
>                 #include "itkListSample.h"
>                 #include "itkCovarianceCalculator.h"
>                 int main( int argc, char * argv[] )
>                 {
>                 const unsigned int vsize = 60;
>                 typedef itk::Vector< float, vsize > InputPixelType;
>                 typedef itk::Statistics::ListSample< InputPixelType >
>                 SampleType ;
>                 SampleType::Pointer sample = SampleType::New() ;
>                 // here I create the samplelist
>                 typedef itk::Statistics::CovarianceCalculator< SampleType >
>                 CovarianceAlgorithmType;
>                 CovarianceAlgorithmType::Pointer covarianceAlgorithm =
>                 CovarianceAlgorithmType::New();
>                 covarianceAlgorithm->SetInputSample( sample );
>                 // I've already calculated the mean:
>                 covarianceAlgorithm->SetMean( meanAlgorithm->GetOutput() );
>                 covarianceAlgorithm->Update();
>                 return 0;
>                 }
>                 /
>                 The error message looks as follows:
>                 /lucas:Seg_Code> make
>                 Building dependencies cmake.check_depends...
>                 Building object file ThresholdSegPrSh.o...
>                 Building executable
>                 /private/var/automount/Seg_Code/ThresholdSegPrSh...
>                 ld: Undefined symbols:
>                 vnl_matrix_fixed<double, (unsigned)60,
>                 (unsigned)60>::div(double const*, double, double*)
>                 vnl_matrix_fixed<double, (unsigned)60,
>                 (unsigned)60>::fill(double)
>                 vnl_matrix_fixed<double, (unsigned)60,
>                 (unsigned)60>::print(std::basic_ostream<char,
>                 std::char_traits<char> >&) const
>                 make[1]: ***
>                 [/private/var/automount/Seg_Code/ThresholdSegPrSh] Error 1
>                 make: *** [default_target] Error 2
>                 /
>                 Could anyone please help me with this problem ?
>                 Thanks,
>                 Lucas Lorenzo
>                 University of Utah
>                 Nora Eccles Harrison CardioVascular Research and
>                 Training Institute
>                 Fellows Room
>                 95 South 2000 East
>                 Salt Lake City, UT 84112-5000
>                 e-mail: lucas at cvrti.utah.edu
>                 telephone: 801-587-9536
>                 ----------------------------------------------------------------------
>                 -- 
>                 _______________________________________________
>                 Insight-users mailing list
>                 Insight-users at itk.org
>                 http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> 
> 
>             _______________________________________________
>             Insight-users mailing list
>             Insight-users at itk.org
>             http://www.itk.org/mailman/listinfo/insight-users
> 
>         Lucas Lorenzo
>         University of Utah
>         Nora Eccles Harrison CardioVascular Research and Training Institute
>         Fellows Room
>         95 South 2000 East
>         Salt Lake City, UT 84112-5000
>         e-mail: lucas at cvrti.utah.edu
>         telephone: 801-587-9536
> 
> 
> 
> 
> 
> Lucas Lorenzo
> 
> University of Utah
> Nora Eccles Harrison CardioVascular Research and Training Institute
> Fellows Room
> 95 South 2000 East
> Salt Lake City, UT 84112-5000
> 
> e-mail: lucas at cvrti.utah.edu
> telephone: 801-587-9536
> 





More information about the Insight-users mailing list