[Insight-users] characteristics

Luis Ibanez luis.ibanez at kitware.com
Thu, 22 Apr 2004 21:17:58 -0400


Hi David,

Here are two possible options.


A) Now that you have labelled the componets
    you could generate N binary images, each
    one having one of the objects in the image.
    If you feed these binary images into the
    ImageMomentsCalculator
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageMomentsCalculator.html 

    you will be able to easily compute the
    coordinates of the center of gravity, and
    the total mass of the object. Given that
    you know the intensity of the mask, this
    mass value is proportional to the surface
    of the object and therefore you can use it
    for estimating the radius. (Assuming that
    the object is actually circular).


B) If you feel adventurous, You could modify the
    code of the ImageMomentsCalculator for accepting
    an additional parameter. This parameter will be
    a label value. Then you go to the Compute() method
    in itkImageMomentsCalculator.txx and introduce
    an IF statement in all the places moments are
    being computed.  The IF should be such that only
    the pixels with intensity equal to the label are
    taken into account.

    You will find the ImageMomentsCalculator under
    Insight/Code/Algorithms.



Note that in both cases you could use the second moments
in order to estimate how far are the shapes from being
circular. If you eigen-analysis the matrix of second order
moments, the ratio of the eigen values will give you an
estimation of excentricity, while the eigen-vectors will
give you orientation. The ratio between second order
moments and zero order moment will allow you to note if
the shapes have any holes (e.g. like a ring), or
invaginations and protrusions (e.g. like a star).



    Regards,



      Luis


---------------------
David Llanos wrote:

> hi all,
>  
> I am looking for classes and methods to obtain characteristic of several 
> objects on a binary image, being the objects separate white parts on 
> black bottom. Of each object I want to obtain the radius and the gravity 
> center. 
> With Ivan Macia's help I believe that I have gotten the first 
> requirement for this objective that is to label this objects, by means 
> of the following code (please, indicate me you if there is some error or 
> if the one labeled is not correct):
> ----------------------------------------------------------------------------------------------------------
>                     .....
>  xorfilter->SetInput1( grindpeak->GetOutput() );
>  xorfilter->SetInput2( binaryDilate->GetOutput() );
>  imgEsperBWsin->SetInput( xorfilter->GetOutput() );
>  imgEsperBWsin->Update();
>  std::cout << "Numero de iteraciones: " << 
> grindpeak->GetNumberOfIterationsUsed() << "  .....bordes borrados" << 
> std::endl;
>     std::cout << "Imagen imgEsperBWsin.jpg creada... " << std::endl;
>  
> // Etiquetado de la imagen
>  itkConnectedComponentFilterType::Pointer labeller =
>   itkConnectedComponentFilterType::New();
>  labeller->SetInput( xorfilter->GetOutput() );
>  labeller->Update();
> 
>  itkRelabelComponentFilterType::Pointer relabeller = 
> itkRelabelComponentFilterType::New();
>  relabeller->SetInput( labeller->GetOutput() );
>  relabeller->Update();
> 
>  // Muestra de resultados
>  unsigned long nObjects = relabeller->GetNumberOfObjects();
>  const std::vector<unsigned long> sizeOfObjects = 
> relabeller->GetSizeOfObjectsInPixels();
>  std::cout << "Number of objects : " << nObjects << std::endl;
>  std::vector<unsigned long>::const_iterator it;
>  int i;  
>  for(i = 0, it =  sizeOfObjects.begin(); it != sizeOfObjects.end(); ++i, 
> ++it) { 
>   std::cout << "Size of object " << i+1 << ": " << (*it) << " pixels" << 
> std::endl;
>  }
> --------------------------------------------------------------------------------------------------------------
>  
> I now need to obtain the radius and the gravity center (two coordinates) 
> of each object, but the classes itkRelabelComponentImageFilter and 
> itkConnectedComponentImageFilter they don't have the methods for it, I 
> eat for example -> GetRadius (). 
> Do I have that instantiate "labeller" or "relabeller" with another 
> class? which advise me you that it uses?
>  
> I attach an example image so that you see to that refer
>  
> Thanks in advange and regards,
>  
> David
>  
>  
> 
>   
> 
> ------------------------------------------------------------------------
>