[Insight-developers] Reading vector images

Miller, James V (Research) millerjv at crd.ge.com
Thu, 13 May 2004 09:27:32 -0400


Okay.

I have part of this working now. There was a minor error in the MetaIO
object wrt to setting ComponentType verses setting PixelType for arrays.

I need to go back and check whether MetaIO writes pixel type in its header
as META_FLOAT_ARRAY when writing vector images.  I may have editted a  
meta header by hand to change a META_FLOAT to a META_FLOAT_ARRAY.

However, most of bug is in the ImageFileReader and ImageIOBase. My current
solution relies on the memory layout for a Vector<T, N> being equivalent to
the
memory layout of an array T[N].  If we can assume this, then I have most
of the trivial case working (I was able to read a meta image with 2D
vectors).

One hurdle is going to be if a file has vectors of floats and the reader is
asked to produce a vector of ints.  I'll need to modify DoConvertPixelBuffer
to handle this.

Interesting that we have a number of examples that read vector images.  What
file formats were these tested on?

Jim



-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: Wednesday, May 12, 2004 7:10 PM
To: Miller, James V (Research)
Cc: Insight-developers (E-mail); Julien Jomier
Subject: Re: [Insight-developers] Reading vector images



Hi Jim,

Yes, this is a known bug in the MetaImage reader.

  http://www.itk.org/Bug/bug.php?op=show&bugid=580&pos=12

Although, as you pointed out, the error may actually
be in the ImageFileReader<> class.


If you have any hints of how to solve it,
please go ahead   :-)


Your suggestion seem to be in the right direction.
We certainly have a lot more types defined in


          ImageIOBase::SetPixelType()

that in

          ImageIOBase::GetPixelType()


They should probably be made symmetrical...



   Luis




------------------------------------
Miller, James V (Research) wrote:

> I just tried to read an image of two component vectors into ITK using 
> the Meta format.
>  
> I get all zeros.
>  
> It looks to me that in ImageFileReader::GenerateData() there is a test for
>  
>       m_ImageIO->GetPixelType() == typeid(TOutputImage::PixelType)
>  
> TOutputImage::PixelType should be Vector<float, 2>
>  
> m_ImageIO->GetPixelType() returns float
>  
> The above check for equality fails and a data conversion occurs.  The 
> result is all zeros.
>  
> It looks as though people have asked this on the list before but I did 
> not find a response.
> I seem to recall people reading vectors as RGB pixels.
>  
> Perhaps if I add a GetPixelType() method to MetaImageIO that checks the 
> m_PixelType to be VECTOR?
>  
>  
>  
> 
> *Jim Miller*
> */_____________________________________/*
> /Visualization & Computer Vision//
> /GE Research/
> /Bldg. KW, Room C218B/
> /P.O. Box 8, Schenectady NY 12301/
> 
> //_millerjv at research.ge.com <mailto:millerjv at research.ge.com>_/
> 
> /_james.miller at research.ge.com_/
> /(518) 387-4005, Dial Comm: 8*833-4005, /
> /Cell: (518) 505-7065, Fax: (518) 387-6981/
> 
>