Mengda Wu | 2 Jan 2007 07:35
Picon

Re: Save Registration Deformation field in ITK and display in VTK glyph

Hi Luis,

   Yes. Option B will work, but need small modifications:

  Replace Line 481-484 with:

  if( this->GetPixelType() == ImageIOBase::VECTOR )
  {
    file << "VECTORS vectors "
      << this->GetComponentTypeAsString(m_ComponentType) << "\n";
  }
  else
  {
    file << "SCALARS scalars "
      << this->GetComponentTypeAsString(m_ComponentType) << " "
      << this->GetNumberOfComponents() << "\n";
    file << "LOOKUP_TABLE default\n";
  }

I also find vtkAssignAttribute in VTK can overcome this problem without modifying ITK. Filter the data with before Glyph:

vtkAssignAttribute *assigner = vtkAssignAttribute::New();
assigner->Assign( vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);

Therefore, I think it is OK without modifying ITK.

Guanglei

2006/12/31, Luis Ibanez <luis.ibanez <at> kitware.com>:


Hi Wei,

Here are a couple of options:


A: Have you tried using the vtkImageReader ?
    instead of using the vtkStructuredPointsReader.



B: Enjoy Open Source: you could modify the itkVTKImageIO.cxx
    file in line 481 in order to write out "VECTORS" instead
    of "SCALARS". You probably want to do this with code such
    as:


     if( this->GetPixeltype() == ImageIOBase::VECTOR )
       {
       file << "SCALARS scalars";
       }
     else
       {
       file << "VECTORS vectors";
       }
    file << this->GetComponentTypeAsString( m_ComponentType)...



"B" is probably a better option. Please give it a try
and let us know if we should make the changes in the
CVS repository.



    Thanks


       Luis


-------------------
Wei Xiong wrote:
> Hi ITKers and VTKers,
>
>    I have some problems in saving and displaying registration
> deformation field in VTK format.
>
> The code in ITK is
>
>    typedef itk::Vector< float, Dimension >    VectorPixelType;
>    typedef itk::Image< VectorPixelType, Dimension > DeformationFieldType;
>    typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;
>    FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
>    fieldWriter->SetFileName( "field.vtk" );
>    fieldWriter->SetInput( nrreg->GetDeformationField() );
>    fieldWriter->Update();
>
> The code in VTK is
>
>   vtkStructuredPointsReader *fieldReader = vtkStructuredPointsReader::New();
>   fieldReader->SetFileName( "field.vtk" );
>   vtkArrowSource *arrow = vtkArrowSource::New();
>   vtkMaskPoints *masker = vtkMaskPoints::New();
>   masker->SetOnRatio( 1000 );
>   masker->RandomModeOn();
>   masker->SetInputConnection( fieldReader->GetOutputPort() );
>   vtkGlyph3D *glyph = vtkGlyph3D::New();
>   glyph->SetInputConnection( masker->GetOutputPort() );
>   glyph->SetScaleModeToScaleByVector();
>   glyph->SetColorModeToColorByVector();
>   glyph->OrientOn();
>   glyph->SetVectorModeToUseVector();
>   glyph->SetSourceConnection( arrow->GetOutputPort() );
>   vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();
>   glyphmapper->SetInputConnection(glyph->GetOutputPort());
>   vtkActor *glyphactor = vtkActor::New();
>
> Displaying in VTK results in all arrows just pointing to one direction,
> say along X-axis.
> I found this is because ITK save field data in VTK using Data Attribute
> in the header:
>
> SCALARS scalars float 3
> LOOKUP_TABLE default
>
> If I manually change it to:
>
> VECTORS vectors float
>
> Then, glyphs are displayed correctly.
>
> I also tried to use itkVTKImageIO to correct this behavior using the code:
>
> typedef itk::VTKImageIO  VTKImageIOType;
> VTKImageIOType::Pointer vtkIO = VTKImageIOType::New();
> vtkIO->SetComponentType( VTKImageIOType::FLOAT );
> vtkIO->SetPixelType( VTKImageIOType::VECTOR );
> fieldWriter->SetImageIO( vtkIO );
>
> ITK just saves in the same way. Don't work.
>
> Can I change the behavior of ITK or is there any filter in VTK can
> correct this?
> Anyone has some ideas on this.
>
> Thank you very much!
> Mengda
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Picon
Favicon

problem with TransformFileReader

Hello,
I am trying to read a Transform File containing the parameters of a 3D  
affine transformation. I get a segmentation fault when trying to read  
the parameters contained in the file, at this point of the code:

TransformListType transforms = transformReader->GetTransformList();
transform->SetParameters((*transforms->begin())->GetParameters());

The transform file looks like this:

#Insight Transform File V1.0
# Transform 0
Transform: AffineTransform_double_3_3
Parameters: 1.00407 0.00202538 -0.000346736 0.00274766 1.00089  
0.00463338 -0.00186666 -0.00160371 0.997568 22.8463 16.5753 -19.3539
FixedParameters: 0 0 0

I have noticed that the segmentation fault occurs when  
"GetParameters()" is executed, but I do not why. Any suggestion that  
may help in finding the problem will be very welcome. Thanks a lot and  
happy new year to everybody.

--

-- 
Xabier Artaechevarria
Cancer Imaging Laboratory
Centre for Applied Medical Research
www.cima.es

----------------------------------------------------------------
Este mensaje ha sido enviado desde https://webmail.unav.es
Luis Ibanez | 2 Jan 2007 14:58
Favicon
Gravatar

Re: problem with TransformFileReader


Hi Xabier,

You probably should check whether the iterator returned by
the "begin()" method is valid or not, before attempting to
use it.

You could use code that looks something like:

TransformListType::const_iterator tit = transforms->begin();
if( tit != transforms->end() )
   {
   const TransformType * readTransform = *tit;
   if( readTransform )
     {
     transform->SetParameters( readTransform->GetParameters() );
     }
   else
     {
     std::cerr << "Invalid Transform pointer" << std::endl;
     }
   }
else
   {
   std::cerr << "Invalid Iterator" << std::endl;
   }

Please give it a try to the code above and let us know
where exactly the run-time error is happening.

   Thanks,

       Luis

=======================================
Xabier Artaechevarria Artieda wrote:
> Hello,
> I am trying to read a Transform File containing the parameters of a 3D  
> affine transformation. I get a segmentation fault when trying to read  
> the parameters contained in the file, at this point of the code:
> 
> TransformListType transforms = transformReader->GetTransformList();
> transform->SetParameters((*transforms->begin())->GetParameters());
> 
> The transform file looks like this:
> 
> #Insight Transform File V1.0
> # Transform 0
> Transform: AffineTransform_double_3_3
> Parameters: 1.00407 0.00202538 -0.000346736 0.00274766 1.00089  
> 0.00463338 -0.00186666 -0.00160371 0.997568 22.8463 16.5753 -19.3539
> FixedParameters: 0 0 0
> 
> I have noticed that the segmentation fault occurs when  
> "GetParameters()" is executed, but I do not why. Any suggestion that  
> may help in finding the problem will be very welcome. Thanks a lot and  
> happy new year to everybody.
> 
Luis Ibanez | 2 Jan 2007 15:05
Favicon
Gravatar

Re: DicomSeriesReadImageWrite2


Hi 예동해

David Clunie kindly pointed out to me the following:

> JPEG lossy (DCT) compression is limited by the JPEG standard
> to 12 bits, because of the word length precision limitations of
> the discrete cosine transformation implementation specification,
> but lossless compression should be supported for 16 bits.
> 

Which lead to think that the warning produced by the JPEG
libraries is incorrect, or that there is something wrong
with the DICOM header of your data.

Could you please try by forcing the GDCMImageIO class to
use JPEG2000 ?

You can do this with the following call:

gdcmImageIO->SetCompressionType( itk::GDCMImageIO::JPEG2000 );

Please try this and let us know if you still receive any
warnings.

  Thanks

    Luis

==============
예동해 wrote:
> First of all, thank you for your concern.
> 
>  
> 
> However, I need your more help.
> 
>  
> 
> I have no idea about how to change the compression mode.
> 
>  
> 
> How can I change lossless compression mode to lossy compression mode?
> 
> 
> Please help me out.
> 
>  
> 
> I'm looking forward to your reply.
> 
>  
> 
> Thank you.
> 
>  
> 
> --- Original Message ---
> *From : * "Luis Ibanez"<luis.ibanez@...>
> *To : * "예동해"<eastsun3@...>
> *Date : * 2006/12/31 일요일 오후 11:38:46
> *Subject : * Re: [Insight-users] DicomSeriesReadImageWrite2
> 
> 
> Hi 예동해
> 
> 
> Are you reading DICOM compressed files ?
> 
> 
> 
> The message:
> 
> "Must downscale data from 16 bits to 12"
> 
> is produced by the JPEG libraries.
> 
> 
> The message is generated from
> 
> Insight/Utilities/itkjpeg/jdinput.c line 54
> 
> when you attempt to use LOSSLESS compression.
> 
> 
> Your options seems to be:
> 
> 
> 
> A) Use Lossy compression
> 
> or
> 
> B) Set the number of bits to 12
> 
> 
> 
> 
> Regards,
> 
> 
> 
> Luis
> 
> 
> 
> ------------
> 예동해 wrote:
>  > Dear all,
>  >
>  > I am trying to convert .dic to .img.
>  >
>  > I used DicomSeriesReadImageWrite2.exe on the example.
>  >
>  >
>  >
>  > It works good, but some warning message comes out.
>  >
>  > The message is "Must downscale data from 16 bits to 12"
>  >
>  >
>  >
>  > How can I get .img without this warning message?
>  >
>  >
>  >
>  > Thank you for your help.
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  > ------------------------------------------------------------------------
>  >
>  > _______________________________________________
>  > Insight-users mailing list
>  > Insight-users@...
>  > http://www.itk.org/mailman/listinfo/insight-users
> 
Picon
Favicon

Re: problem with TransformFileReader

Hi Luis,
Thanks for your rapid answer.
I actually solved the problem by updating the Transform Reader before  
GetParameters(). I forgot it because I am used to ImageToImage  
filters, where a single Update() in the end is enough to execute the  
whole pipeline.
Best regards,
Xabi

-- 
Xabier Artaechevarria
Cancer Imaging Laboratory
Centre for Applied Medical Research
www.cima.es

Luis Ibanez <luis.ibanez@...> ha escrito:

>
> Hi Xabier,
>
> You probably should check whether the iterator returned by
> the "begin()" method is valid or not, before attempting to
> use it.
>
>
> You could use code that looks something like:
>
>
> TransformListType::const_iterator tit = transforms->begin();
> if( tit != transforms->end() )
>   {
>   const TransformType * readTransform = *tit;
>   if( readTransform )
>     {
>     transform->SetParameters( readTransform->GetParameters() );
>     }
>   else
>     {
>     std::cerr << "Invalid Transform pointer" << std::endl;
>     }
>   }
> else
>   {
>   std::cerr << "Invalid Iterator" << std::endl;
>   }
>
>
> Please give it a try to the code above and let us know
> where exactly the run-time error is happening.
>
>
>   Thanks,
>
>
>       Luis
>
>
>
> =======================================
> Xabier Artaechevarria Artieda wrote:
>> Hello,
>> I am trying to read a Transform File containing the parameters of a  
>>  3D affine transformation. I get a segmentation fault when trying  
>> to  read the parameters contained in the file, at this point of the  
>> code:
>>
>> TransformListType transforms = transformReader->GetTransformList();
>> transform->SetParameters((*transforms->begin())->GetParameters());
>>
>> The transform file looks like this:
>>
>> #Insight Transform File V1.0
>> # Transform 0
>> Transform: AffineTransform_double_3_3
>> Parameters: 1.00407 0.00202538 -0.000346736 0.00274766 1.00089    
>> 0.00463338 -0.00186666 -0.00160371 0.997568 22.8463 16.5753 -19.3539
>> FixedParameters: 0 0 0
>>
>> I have noticed that the segmentation fault occurs when    
>> "GetParameters()" is executed, but I do not why. Any suggestion   
>> that  may help in finding the problem will be very welcome. Thanks   
>> a lot and happy new year to everybody.
>>

----------------------------------------------------------------
Este mensaje ha sido enviado desde https://webmail.unav.es
Matei Stroila | 2 Jan 2007 18:03
Picon

Re: ITK and iterators debugging in Visual Studio 8

First of all, Happy New Year!

Thanks all for this wonderful software library! It is an exemplary
model of open source software that helps progress go on.

Now, going back to the VS 2005 settings:

Luis,

I added

#cmakedefine _SECURE_SCL=0
#cmakedefine _HAS_ITERATOR_DEBUGGING=0

in itkConfigure.h.in.

The  itkConfigure.h in the build dir becomes:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
 * here is where system computed values get stored these values should only
 * change when the target compile platform changes
 */

/* what byte order */
/* #undef CMAKE_WORDS_BIGENDIAN */
#ifdef CMAKE_WORDS_BIGENDIAN
  #define ITK_WORDS_BIGENDIAN
#endif

/* what threading system are we using */
/* #undef CMAKE_USE_PTHREADS */
#ifdef CMAKE_USE_PTHREADS
#define ITK_USE_PTHREADS
#endif

/* #undef CMAKE_USE_SPROC */
#ifdef CMAKE_USE_SPROC
#define ITK_USE_SPROC
#endif

/* #undef CMAKE_HP_PTHREADS */
#ifdef CMAKE_HP_PTHREADS
#define ITK_HP_PTHREADS
#endif

#define CMAKE_USE_WIN32_THREADS
#ifdef CMAKE_USE_WIN32_THREADS
#define ITK_USE_WIN32_THREADS
#endif

/* #undef ITK_BUILD_SHARED_LIBS */
#ifdef ITK_BUILD_SHARED_LIBS
#define ITKDLL
#else
#define ITKSTATIC
#endif

/* #undef CMAKE_NO_STD_NAMESPACE */
/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */
/* #undef CMAKE_NO_ANSI_STRING_STREAM */
/* #undef CMAKE_NO_ANSI_FOR_SCOPE */
#define ITK_CPP_FUNCTION
/* #undef ITK_USE_CONCEPT_CHECKING */
/* #undef ITK_EXPLICIT_INSTANTIATION */
/* #undef USE_FFTWF */
/* #undef USE_FFTWD */
/* #undef _SECURE_SCL=0 */
/* #undef _HAS_ITERATOR_DEBUGGING=0 */

#define ITK_VERSION_MAJOR 3
#define ITK_VERSION_MINOR 1
#define ITK_VERSION_PATCH 0
#define ITK_VERSION_STRING "3.1"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

The  _SECURE_SCL and _HAS_ITERATOR_DEBUGGING do not get defined,
neither in the ITK library nor in projects depending on it.

On the other hand, if I add:

#define _SECURE_SCL 0
#define _HAS_ITERATOR_DEBUGGING 0

in the itkConfigure.h.in, then they appear as is in itkConfigure.h but
I get compile errors in
C:\Program Files\Microsoft Visual Studio 8\VC\include\deque:

Error	21	error C2248: 'std::deque<_Ty>::_Myoff' : cannot access
protected member declared in class 'std::deque<_Ty>'	C:\Program
Files\Microsoft Visual Studio 8\VC\include\deque	132

So, for now I will keep the definitions in CMakeLists.txt since that works well.

Matei

On 12/31/06, Luis Ibanez <luis.ibanez@...> wrote:
>
> Hi Matei,
>
> When adding cmakedefine statements to  itkConfigure.h.in,
> they will only appear in the file
>
>                       itkConfigure.h
>
> that CMake generates in the Binary directory where you are
> building ITK (and the install directory,... if you  are
> installing ITK after building it).
>
>
> The symbol does not appear in the CMake configuration editor, and
> it does not appear in the properties of Visual Studio IDE. This
> is normal. It is actually part of the advantages of defining the
> symbol in the itkConfigure.h.in file.
>
>
> Since itkConfigure.h is included by almost all ITK files, the symbol
> will be used all through your build.
>
>
> For a simple verification you can try adding in your
> code something like:
>
>
>        #ifndef _HAS_ITERATOR_DEBUGGING
>        #error ITERATOR_DEBUGING_NOT_DEFINED
>        #endif
>
>
>
> Please let us know if you find an indication that the symbol does
> not get defined correctly.
>
>
>    Thanks
>
>
>      Luis
>
>
>
> ---------------------
> Matei Stroila wrote:
> > I added
> >
> > # cmakedefine  _HAS_ITERATOR_DEBUGGING=0
> >
> > to   Insight/itkConfigure.h.in, line 49
> >
> > but I don't see it  in the CMake configuration editor, neither in the
> > Properties Window of the ITK projects. It does not look like they are
> > using it.
> >
> > Also, for people intersted in using VS 2005, this define is also necessary:
> > _SECURE_SCL=0
> >
> >
> > Matei
> >
> > On 12/27/06, Luis Ibanez <luis.ibanez@...> wrote:
> >
> >>
> >> Hi Matei, Karthik
> >>
> >>
> >> Thanks for tracking this issue.
> >>
> >>
> >> Just for the record:
> >>
> >> a better place for adding definitions is the file:
> >>
> >>
> >>              Insight/itkConfigure.h.in
> >>
> >>
> >> Where you could add the line 49:
> >>
> >>
> >>      cmakedefine  _HAS_ITERATOR_DEBUGGING=0
> >>
> >>
> >> The advantage of adding the definition here instead of the
> >> CMakeLists.txt file is that in the itkConfigure.h file, the
> >> definition is actually passed also to the projects that use
> >> ITK, while the definitions in CMakeLists.txt are used only
> >> while building ITK.
> >>
> >>
> >>
> >>     Regards,
> >>
> >>
> >>
> >>         Luis
> >>
> >>
> >> ----------------------
> >> Matei Stroila wrote:
> >> > Thank you very much.
> >> >
> >> > I added   -D_HAS_ITERATOR_DEBUGGING=0  in  Insight\CMakeLists.txt :
> >> >
> >> > IF(WIN32)
> >> >  IF(NOT BORLAND)
> >> >    IF(NOT CYGWIN)
> >> >      IF(NOT MINGW)
> >> >          ADD_DEFINITIONS(
> >> >            -D_HAS_ITERATOR_DEBUGGING=0
> >> >            )
> >> >      ENDIF(NOT MINGW)
> >> >    ENDIF(NOT CYGWIN)
> >> >  ENDIF(NOT BORLAND)
> >> > ENDIF(WIN32)
> >> >
> >> >
> >> > Recompiled and my program runs fine in debug.
> >> >
> >> >> Please log this issue as an entry in the bug tracker.
> >> >>
> >> >
> >> > Sure, I will do it now.
> >> >
> >> > Thanks,
> >> >
> >> > Matei
> >> >
> >>
> >
>
Richard Pradenas | 3 Jan 2007 02:00
Picon
Favicon

building itk

Hello,
 
I am a new itk user (actually, attempting to become one).  I've downloaded itk (version 3.0.0) and cmake (version 2.4 patch 5).
 
I have a screen shot of the cmake setup (I'm running windows XP) that shows the settings for paths, etc. that I can send.  (The email is too large with the screen shot attached.)
 
When I "Configure" I get the following message (in a dialog box) for each source directory under Code (Common, Numerics, Basic Filters, ..., SpatialObject).
 
"INSTALL TARGETS given no DESTINATION"
 
I looked for any threads addressing this on the mailing lists but found no information.  It seems most people get further along in the build process before they encounter any problems.
 
Any help you could give to get me past this and on to building itk would be appreciated.
 
Thanking you in advance,
 
Richard Pradenas
_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
Ali - | 3 Jan 2007 15:29
Picon
Favicon

Circule detection in itk

Hi,

Is there any existing implemented algorithm in ITK for detecting circular objects? I understand that itk::HoughTransform2DCirclesImageFilter may do this, but Hough transform is not efficient for circle detection.

Be one of the first to try Windows Live Mail.
_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
roger t | 4 Jan 2007 04:07
Picon
Favicon

newbie question - problems running examples/datarepresentation/image/rgbimage.cxx

I was finally successful in compiling and running the "hello world" program. Now I am trying to run the RGB Image example program rgbimage.cxx in the examples folder but the program crashes in the function call-

 reader->Update();

in the first line in -

template <class TOutputImage, class ConvertPixelTraits>
void ImageFileReader<TOutputImage, ConvertPixelTraits> ::EnlargeOutputRequestedRegion(DataObject *output)
{
typename TOutputImage::Pointer out = dynamic_cast<TOutputImage*>(output);//crash
...
...
..
}


How do I debug whats going wrong? Again, I am directly compiling (VS6) and using the example code.

Thanks in advance,
Roger

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Insight-users mailing list
Insight-users@...
http://www.itk.org/mailman/listinfo/insight-users
Mathieu Malaterre | 4 Jan 2007 17:21
Favicon

Re: DicomSeriesReadImageWrite2

예동해 wrote:
> Dear all,
> 
> I am trying to convert .dic to .img.
> 
> I used DicomSeriesReadImageWrite2.exe on the example.
> 
>  
> 
> It works good, but some warning message comes out.
> 
> The message is "Must downscale data from 16 bits to 12"

Hi 예동해,

  This is a warning you can simply discard it. To only way to safely
remove this warning is to call your private vendor that delivered this
buggy DICOM file. Basically the DICOM header is saying that the JPEG
stream will be encoded on 16bits, but when reading the raw jpeg segment
GDCM (Actually ijg) is finding that the jpeg stream was encoded only on
12bits, thus the warning. In a fully compliant system (eg dcmtk) the
image will not (shall not !) be decompressed correctly since the only
information we should be using is the one specified in the DICOM header.

  I only see that happen on some old Philips DICOM file, by any chance
could you please send me a copy of this file.

2 cents,
Mathieu

Gmane