[Insight-users] ~vnl_svd() {} misterious runtime error

Luis Ibanez luis.ibanez at kitware.com
Thu Apr 15 20:55:55 EDT 2010


Hi Osc,

Thanks for providing this additional information.


It would look like the VTK image that you are
reading is inconsistent, and end up having a
null value of spacing in one of the directions.

Please do the following:

    Test first only the VTK part of the code.

Disconnect the ITK adaptor and replace it
with a vtkMetaImageWriter.

You will have a VTK pipeline such as:

vtkImageReader2 --->  vtkMetaImageWriter

save the image using a filename such as

                 myImage.mhd

and post to the list the content of the .mhd
header. ( it should contain about ten lines
of ASCII text describing the image grid
parameters).


   Thanks


          Luis


-------------------------------------------
On Tue, Apr 13, 2010 at 10:45 PM, Osc at r Math <olguna at cimat.mx> wrote:

>  Hi Luis…
>
> Here’s my base code…
>
>
>
> //Variables CLASS Private:
>
> int bounds[6]; {0,255,0,255,0,63}
>
> int bigEnd,//false
>
> dataType, //4àFLOAT
>
> header; //0
>
> double xSpacing=1.0,
>
>                 ySpacing=1.0,
>
>                 zSpacing=2.0,
>
>                 *scalarRange;
>
> vtkImageReader2 *fileReader;
>
>
>
> On Constructor
>
> fileReader = vtkImageReader2::New();
>
>
>
>
>
> ReaderFunction(FileName)
>
> {
>
> fileReader->SetFileName(fileName);
>
> fileReader->SetDataExtent(0,bounds[1], 0, bounds[3], 0, bounds[5]);
>
> switch (dataType)
>
>   {
>
>   case 0 :
>
>     fileReader->SetDataScalarTypeToUnsignedChar();
>
>     break;
>
>   case 1 :
>
>     fileReader->SetDataScalarTypeToUnsignedShort();
>
>     break;
>
>   case 2 :
>
>     fileReader->SetDataScalarTypeToShort();
>
>     break;
>
>   case 3 :
>
>     fileReader->SetDataScalarTypeToInt();
>
>     break;
>
>   case 4 :
>
>     fileReader->SetDataScalarTypeToFloat();
>
>     break;
>
>   case 5 :
>
>     fileReader->SetDataScalarTypeToDouble();
>
>     break;
>
>   }
>
>
>
> fileReader->SetHeaderSize(header);
>
> *fileReader->SetDataSpacing(xSpacing, ySpacing, zSpacing);*
>
>
>
>   fileReader->SetDataByteOrderToLittleEndian();
>
> try {
>
>   fileReader->Update();}
>
> catch(...){
>
>   return false;  }
>
> scalarRange = fileReader->GetOutput()->GetScalarRange();
>
>
>
>
>
> That’s the reader code, then show data into a vtkBorland Package, cause i´m
> compiling in BCB5. Everything is OK.
>
>
>
> The problem starts when connect VTKReader with ITKPIpeline via a
> VTKExporter itkVTKImporter
>
>
>
> Next One is a function that just export VTK data to ITK data.
>
> template<typename InputPixelType>
>
> bool VTKtoITK()
>
> {
>
>                 //Definiendo e /*Instanciando*/... para la tarea de
> exportacion_VTK/Importacion_ITK
>
>                                //Exportador de VTK
>
>                 vtkImageExport *vtkExporter=vtkImageExport::New();
>
>                                //Tipo de dato e imagen a leer sobre el tipo
> "templado" <InputPixelType>
>
>                 typedef itk::Image<InputPixelType,Dimension>
> InputImageType;  //Dimension=3;
>
>                                //Filtro de importacion ITK
>
>                 typedef itk::VTKImageImport<InputImageType>
> ImportImageFilterType;
>
>                                //Importador de ITK
>
>                 ImportImageFilterType::Pointer
> itkImageImporter=ImportImageFilterType::New();
>
>
>
>                                //El exportador toma los datos leidos por
> el plugin
>
>                 vtkExporter->SetInput(fileReader->GetOutput());
>
>                                //Se conecta el importador de ITK
>
>                 ConnectPipelines(vtkExporter, itkImageImporter);
>
>  try {
>
>     itkImageImporter->Update(); }//executes VTKexportàITK Import
>
>                 catch (itk::ExceptionObject & exp) {
>
>                                                //Algun error ocurrio en la
> linea de procesos...
>
>     INFORME="Falla de Exportacion"; return false;}
>
> Return true;}
>
>
>
>
>
>
>
> template <typename VTK_Exporter, typename ITK_Importer>
>
> void ConnectPipelines(VTK_Exporter *exporter, ITK_Importer importer)
>
> {
>
>   importer->SetUpdateInformationCallback
> (exporter->GetUpdateInformationCallback());
>
>   importer->SetPipelineModifiedCallback
> (exporter->GetPipelineModifiedCallback());
>
>   importer->SetWholeExtentCallback
> (exporter->GetWholeExtentCallback());
>
>   importer->SetSpacingCallback
> (exporter->GetSpacingCallback());
>
>   importer->SetOriginCallback
> (exporter->GetOriginCallback());
>
>   importer->SetScalarTypeCallback
> (exporter->GetScalarTypeCallback());
>
>   importer->SetNumberOfComponentsCallback
> (exporter->GetNumberOfComponentsCallback());
>
>   importer->SetPropagateUpdateExtentCallback
> (exporter->GetPropagateUpdateExtentCallback());
>
>   importer->SetUpdateDataCallback
> (exporter->GetUpdateDataCallback());
>
>   importer->SetDataExtentCallback
> (exporter->GetDataExtentCallback());
>
>   importer->SetBufferPointerCallback
> (exporter->GetBufferPointerCallback());
>
>   importer->SetCallbackUserData
> (exporter->GetCallbackUserData());
>
> }
>
>
>
> When ITK tries to import data, occurs the errors listed before…
>
>
>
> TNX by answers…
>
>
>
>
>
> *De:* Luis Ibanez [mailto:luis.ibanez at kitware.com]
> *Enviado el:* Sábado, 10 de Abril de 2010 08:54 a.m.
> *Para:* Osc at r Math
> *CC:* Insight-users at itk.org
> *Asunto:* Re: [Insight-users] ~vnl_svd() {} misterious runtime error
>
>
>
>
> Hi Osc,
>
> Thanks for posting the details from your debugging session.
>
> It looks like the "outSpacing" variable is not initialized correctly.
>
> In a 3D image, this arrays is expected to have three elements.
>
>
> We may have to go to your original code in order to trace the
> problem. Could you post the code ?
>
>
> Any chance that you can compile this with GCC ?
> and run Valgrind on it ?
>
>
> That will be an effective way of locating uninitialized variables...
>
>
>     Regards
>
>
>            Luis
>
>
> --------------------------------------------------------------------------
>
> On Fri, Apr 9, 2010 at 9:58 PM, Osc at r Math <olguna at cimat.mx> wrote:
>
> Again Myself…
>
>
>
> I´ve been debugging and find that error starts on
>
>
>
> Command
>
> output->SetSpacing(outSpacing);
>
>
>
> Function
>
> template <typename TOutputImage>
>
> void VTKImageImport<TOutputImage>::GenerateOutputInformation()
>
> File
>
>                 itkVTKImageImport.txx
>
>
>
> Debugging information
>
>                 outSpacing is generated like:
>
>                                 typename TOutputImage::SpacingType
> outSpacing;
>
> This is the result by traspase inSpacing data
>
>                                 outSpacing: { ????, ????, ????, { 1, 1, 2 }
> };
>
>          {WSH?,WSH?,WSH?, { xSpacing,ySpacing,zSpacing } }.
>
>         WSH?:=What Suppose to be here?
>
>
>
> Those data passes to
>
> if( this->m_Spacing != spacing )  HERE m_Spacing=
>
>     {
>
>     this->m_Spacing = spacing;
>
>     this->ComputeIndexToPhysicalPointMatrices();
>
>     this->Modified();
>
>     }
>
> Command:         this->ComputeIndexToPhysicalPointMatrices();
>
> Function:            Void ImageBase<VImageDimension>::SetSpacing(const
> SpacingType & spacing )
>
> FILE:                      itkImageBase.txx
>
> Var Keeps:         spacing: { ????, ????, ????, { 1, 1, 2 } };
>
>
>
>
>
> Command:         this->Superclass::ComputeIndexToPhysicalPointMatrices();
>
> Function:            void Image<TPixel,
> VImageDimension>::ComputeIndexToPhysicalPointMatrices()
>
> FILE:                      itkImage.txx
>
> Var keeps:          m_Spacing: { ????, ????, ????, { 1, 1, 2 } }
>
>
>
> Command:         this->m_PhysicalPointToIndex =
> m_IndexToPhysicalPoint.GetInverse();
>
> Function:            void
> ImageBase<VImageDimension>::ComputeIndexToPhysicalPointMatrices()
>
> FILE:                      itkImageBase.txx
>
> Var keeps:          m_Spacing: { ????, ????, ????, { 1, 1, 2 } }
>
>
>
> Command:         vnl_matrix<T> temp = vnl_matrix_inverse<T>( m_Matrix );
>
> Function:            inline vnl_matrix_fixed<T,NColumns,NRows> GetInverse(
> void ) const
>
> FILE:                      itkMatrix.h
>
> Data keeps:       m_Matrix: { { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 2 } } }
>
>
>
> Command & Function:
>
> operator const vnl_matrix_ref<T>() const { return vnl_matrix_ref<T>(
> num_rows, num_cols, const_cast<T*>(data_block()) ); }
>
> *data_block: E2335 Overloaded 'vnl_matrix_fixed<double, 3, 3>::data_block'
> ambiguous in this context
>
>
>
> Command & Function:
>
> T const* data_block () const { return data_[0]; }
>
> DATA:   *data_: { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 2 }
>
>
>
> And so on, but I couldn´t  find the error…
>
>
>
>
>
>
>
>
>
> *De:* insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org]
> *En nombre de *Osc at r Math
> *Envia**do el:* Viernes, 09 de Abril de 2010 07:09 p.m.
> *Para:* insight-users at itk.org
> *Asunto:* [Insight-users] ~vnl_svd() {} misterious runtime error
>
>
>
> Hi All…!!!
>
>
>
> Recently I took back an ITK-VTK-BCB5 project, but as I know ITK & VTK
> improves, I decided to update those toolkits (by the way, congrats!!! For
> this big effort).
>
> Actually, compiled ITK 3.16 & VTK 5.4.2 Releases
>
> BCB 5 with Borland C++ compiler 5.5.
>
>
>
> Today I  get a runtime error that it’s pretty mysterious (at least for me)…
>
>
>
> The application reads a 3D image by VTK reader, show it by VTK
> renderization, send it to ITK pipeline, calculates partial derivatives &
> magnitude gradient, then save Dx, Dy, Dz & |V|.
>
>
>
> The image has a spacing, an origin, among others…
>
> When spacing is 1.0, 1.0, 1.0 there’s no problem, everything works fine,
>
> but if spacing changes anyone of those dimensions, application crashes.
>
>
>
> The application is capable to read image, show it, but when tries to
> connect VTKReader to ITKCaster (is first action with ITK) send an “Abnormal
> Program Termination”
>
>
>
> In Debug mode I realize that crashes trying to execute
>
> ~vnl_svd() {}
>
> In vnl_svd.h file and mark an error like:
>
> … Access violation at address XXXX …
>
> If continue debugging, crashes too in:
>
> ~vnl_diag_matrix() {}
>
> In vnl_diag_matrix.h file with similar error
>
> And finally throws an “Abnormal Program Termination”…
>
>
>
> I didn´t know why tries to invert a matrix that contains
>
> xSpacing     0                      0
>
>        0      ySpacing              0
>
>       0             0               zSpacing
>
>
>
> ¡¡¡ Someone could help me !!!
>
>
>
> TNX in advance
>
>
>
> __________ Información de ESET Smart Security, versión de la base de firmas
> de virus 5014 (20100409) __________
>
> ESET Smart Security ha comprobado este mensaje.
>
> http://www.eset.com
>
>
> __________ Información de ESET Smart Security, versión de la base de firmas
> de virus 5014 (20100409) __________
>
> ESET Smart Security ha comprobado este mensaje.
>
> http://www.eset.com
>
>
>
> __________ Información de ESET Smart Security, versión de la base de firmas
> de virus 5014 (20100409) __________
>
> ESET Smart Security ha comprobado este mensaje.
>
> http://www.eset.com
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
>
> __________ Información de ESET Smart Security, versión de la base de firmas
> de virus 5026 (20100413) __________
>
>
> ESET Smart Security ha comprobado este mensaje.
>
> http://www.eset.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100415/6433af4d/attachment-0001.htm>


More information about the Insight-users mailing list