[Insight-users] CovarianceCalculator
Sayan Pathak
spathak at insightful.com
Mon Jun 21 14:03:59 EDT 2004
Hi Lucas,
In general to do statistical calculation there are several methods in
http://www.itk.org/Doxygen16/html/namespaceitk_1_1Statistics.html. In
addition the software guide has a chapter on Statistics. This may be
sufficient for your purpose. However, if you need to work directly with
images instead of treating the data as a list of pixels. The following class
I believe might be useful.
<http://www.itk.org/Doxygen16/html/classitk_1_1ImageModelEstimatorBase.html>
itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >
* itk::ImageGaussianModelEstimator
<http://www.itk.org/Doxygen16/html/classitk_1_1ImageGaussianModelEstimator.ht
ml> < TInputImage, TMembershipFunction, TTrainingImage >
There are tests associated with this class in the testing directory. The
training image could be a mask with unique label for all the pixels in the
data you want to build your model on.
The itk::ImageClassifierBase
<http://www.itk.org/Doxygen16/html/classitk_1_1ImageClassifierBase.html> <
TInputImage, TClassifiedImage > class allows the usage different model while
working with images for classification. It is possible for you to derive your
class from the classifier base with the appropriate components or use the
some components from the classifier base within your class as a helper class
depending on what works best for you.
For instance, the MRF filter class ( itk::MRFImageFilter
<http://www.itk.org/Doxygen16/html/classitk_1_1MRFImageFilter.html> <
TInputImage, TClassifiedImage >) uses the image classifier class. There is
test code in the testing directory, you could leverage your implementation by
looking into this code.
Note: all the images take vector value input as is the case with your data.
Regards,
Sayan
-----Original Message-----
From: Lucas Lorenzo [mailto:lucas at cvrti.utah.edu]
Sent: Wednesday, June 16, 2004 1:32 PM
To: Luis Ibanez
Cc: ITK
Subject: Re: [Insight-users] CovarianceCalculator
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20040621/3553ef0c/attachment-0001.html
More information about the Insight-users
mailing list