[Insight-users] 答复: 答复: 答复: Problem With ITKImageIO

吴鹏飞 wpfnihao at gmail.com
Thu Jul 5 22:54:46 EDT 2012


Hi Saurabh,

Thanks for your help. I've tried the method and it works, but needs some
additional job.

In the file "itkImageFileReader.h", I see the statements 

#ifdef ITK_IO_FACTORY_REGISTER_MANAGER
#include "itkImageIOFactoryRegisterManager.h"
#endif

I think that’s why the macro defined before #include <itkImageFileReader.h>
matters.
However, The file "itkImageIOFactoryRegisterManager.h" is not in the include
directory of itk.
It appears in three places:
1) 	/InsightApplications-4.1.1_bin/ITKIOFactoryRegistration
2)
/InsightApplications-4.1.1_bin/VolviewPlugIns/ITKIOFactoryRegistration
3)	/ITK_Bin/Examples/ITKIOFactoryRegistration
Where InsightApplications-4.1.1_bin and ITK_Bin are the directories I put
the project generated by CMake from InsightApplications and InsightToolkit,
respectively.
Add any of the three into the include directories will be ok.

Regards,
Wu

-----邮件原件-----
发件人: Saurabh Garg [mailto:srbh.garg at gmail.com] 
发送时间: 2012年7月6日 1:11
收件人: 吴鹏飞
抄送: Bill Lorensen; insight-users at itk.org
主题: Re: [Insight-users] 答复: 答复: Problem With ITKImageIO

Hi Pengfei Wu,

I had the same problem as yours when I was using ITK with QT. I have
compiled ITK using cmake but for QT applications I was using qmake. I did
the following steps and was able to make it work. I hope the same steps will
help you:

Define this variable (ITK_IO_FACTORY_REGISTER_MANAGER) before you include
itkImageFileReader.h file. This will register all the different IOs and then
you can use them.
-----------------
#define ITK_IO_FACTORY_REGISTER_MANAGER
#include <itkImageFileReader.h>
-----------------

Also the order in which you link the libraries, matters. Here is the order
which worked for me:
-----------------------------
-lITKIOVTK-4.1 \
-lITKIOStimulate-4.1 \
-lITKIOBioRad-4.1 \
-lITKIOLSM-4.1 \
-lITKIOGDCM-4.1 \
-litkgdcmMSFF-4.1 \
-litkgdcmDSED-4.1 \
-litkgdcmDICT-4.1 \
-litkgdcmIOD-4.1 \
-lITKIOHDF5-4.1 \
-lITKIOTransformHDF5-4.1 \
-litkhdf5_cpp-4.1 \
-lITKReview-4.1 \
-lITKDeprecated-4.1 \
-lITKFEM-4.1 \
-lITKIOMeta-4.1 \
-lITKIONIFTI-4.1 \
-lITKIOImageBase-4.1 \
-lITKDICOMParser-4.1 \
-lITKIOGE-4.1 \
-lITKIOBMP-4.1 \
-lITKIOPNG-4.1 \
-lITKIOGIPL-4.1 \
-litkgdcmjpeg12-4.1 \
-litkgdcmjpeg16-4.1 \
-litkgdcmjpeg8-4.1 \
-lITKIOJPEG-4.1 \
-lITKIOTIFF-4.1 \
-lITKSpatialObjects-4.1 \
-lITKMetaIO-4.1 \
-lITKEXPAT-4.1 \
-lITKniftiio-4.1 \
-lITKgiftiio-4.1 \
-lITKznz-4.1 \
-litkgdcmCommon-4.1 \
-litkjpeg-4.1 \
-litkopenjpeg-4.1 \
-litkpng-4.1 \
-litktiff-4.1 \
-litkhdf5-4.1 \
-litkzlib-4.1 \
-lITKIONRRD-4.1 \
-lITKCommon-4.1 \
-lITKNrrdIO-4.1 \
-lITKVNLInstantiation-4.1 \
-litkvnl_algo-4.1 \
-litkv3p_netlib-4.1 \
-litkv3p_lsqr-4.1 \
-litkvnl-4.1 \
-litkvcl-4.1 \
-litksys-4.1 \
-lITKStatistics-4.1 \
-lgdi32 \
-lsnmpapi -lrpcrt4 -lwsock32
--------------------------------


HTH.
Saurabh

On Thu, Jul 5, 2012 at 9:26 AM, 吴鹏飞 <wpfnihao at gmail.com> wrote:
>
> Thanks for your advice. I’ll study the examples.
>
>
>
> 发件人: Bill Lorensen [mailto:bill.lorensen at gmail.com]
> 发送时间: 2012年7月5日 23:46
> 收件人: 吴鹏飞
> 抄送: insight-users at itk.org
> 主题: Re: 答复: [Insight-users] Problem With ITKImageIO
>
>
>
> It is not easy to use ITKv4 without cmake. There are many examples on the
wiki that include sample cmake files. See for example see:
>
> http://itk.org/Wiki/ITK/Examples/QuickView
>
>
>
>
>
> On Thu, Jul 5, 2012 at 10:49 AM, 吴鹏飞 <wpfnihao at gmail.com> wrote:
>
> Hi Bill,
>
>          Thanks for your reply. But I use VS 2010 to compile the code, I’
m not familiar with the CMake grammar.
>
>
>
> Here’s some information of my project (the vtk related info. is omitted).
>
>
>
> The include directory:
>
> C:\Program Files (x86)\ITK\include\ITK-4.1
>
> C:\Program Files (x86)\ITK\include
>
>
>
> The library directory:
>
> C:\Program Files (x86)\ITK\lib
>
>
>
> Additional dependence (I include all the lib files in the  ./ITK/lib
directory):
>
> itksys-4.1.lib
>
> itkvnl_algo-4.1.lib
>
> itkvnl-4.1.lib
>
> itkv3p_netlib-4.1.lib
>
> ITKCommon-4.1.lib
>
> itkNetlibSlatec-4.1.lib
>
> ITKStatistics-4.1.lib
>
> ITKIOImageBase-4.1.lib
>
> ITKIOBMP-4.1.lib
>
> ITKIOBioRad-4.1.lib
>
> ITKEXPAT-4.1.lib
>
> itkopenjpeg-4.1.lib
>
> itkzlib-4.1.lib
>
> itkgdcmDICT-4.1.lib
>
> itkgdcmMSFF-4.1.lib
>
> ITKIOGDCM-4.1.lib
>
> ITKIOGIPL-4.1.lib
>
> itkjpeg-4.1.lib
>
> ITKIOJPEG-4.1.lib
>
> itktiff-4.1.lib
>
> ITKIOTIFF-4.1.lib
>
> ITKIOLSM-4.1.lib
>
> ITKMetaIO-4.1.lib
>
> ITKIOMeta-4.1.lib
>
> ITKznz-4.1.lib
>
> ITKniftiio-4.1.lib
>
> ITKIONIFTI-4.1.lib
>
> ITKNrrdIO-4.1.lib
>
> ITKIONRRD-4.1.lib
>
> itkpng-4.1.lib
>
> ITKIOPNG-4.1.lib
>
> ITKIOStimulate-4.1.lib
>
> ITKIOVTK-4.1.lib
>
> ITKMesh-4.1.lib
>
> ITKSpatialObjects-4.1.lib
>
> ITKPath-4.1.lib
>
> ITKLabelMap-4.1.lib
>
> ITKQuadEdgeMesh-4.1.lib
>
> ITKOptimizers-4.1.lib
>
> ITKPolynomials-4.1.lib
>
> ITKBiasCorrection-4.1.lib
>
> ITKBioCell-4.1.lib
>
> ITKDICOMParser-4.1.lib
>
> ITKIOXML-4.1.lib
>
> ITKIOSpatialObjects-4.1.lib
>
> ITKFEM-4.1.lib
>
> ITKIOIPL-4.1.lib
>
> ITKIOGE-4.1.lib
>
> ITKIOSiemens-4.1.lib
>
> ITKKLMRegionGrowing-4.1.lib
>
> ITKVTK-4.1.lib
>
> ITKWatersheds-4.1.lib
>
> ITKDeprecated-4.1.lib
>
> ITKgiftiio-4.1.lib
>
> ITKIOMesh-4.1.lib
>
> itkhdf5_cpp-4.1.lib
>
> itkhdf5-4.1.lib
>
> ITKIOCSV-4.1.lib
>
> ITKIOHDF5-4.1.lib
>
> ITKIOTransformBase-4.1.lib
>
> ITKIOTransformHDF5-4.1.lib
>
> ITKIOTransformInsightLegacy-4.1.lib
>
> ITKIOTransformMatlab-4.1.lib
>
> ITKOptimizersv4-4.1.lib
>
> ITKReview-4.1.lib
>
> ITKVideoCore-4.1.lib
>
> ITKVideoIO-4.1.lib
>
> itkgdcmIOD-4.1.lib
>
> itkgdcmDSED-4.1.lib
>
> itkgdcmCommon-4.1.lib
>
> itkgdcmjpeg8-4.1.lib
>
> itkgdcmjpeg12-4.1.lib
>
> itkgdcmjpeg16-4.1.lib
>
> rpcrt4.lib
>
> comctl32.lib
>
> wsock32.lib
>
> ws2_32.lib
>
> ITKVNLInstantiation-4.1.lib
>
> itkv3p_lsqr-4.1.lib
>
> itkvcl-4.1.lib
>
>
>
>
>
> Regards,
>
> Wu, Pengfei
>
>
>
> 发件人: Bill Lorensen [mailto:bill.lorensen at gmail.com]
> 发送时间: 2012年7月5日 22:19
> 收件人: 吴鹏飞
> 抄送: insight-users at itk.org
> 主题: Re: [Insight-users] Problem With ITKImageIO
>
>
>
> Please show us your CMakeLists.txt file.
>
> On Thu, Jul 5, 2012 at 7:57 AM, 吴鹏飞 <wpfnihao at gmail.com> wrote:
>
> Hello all,
>
>
>
> I am new to itk and tried to write my first program using itk and vtk 
> to show an image, but I encountered a strange problem. It seems that 
> my itk can’t infer from the file extension which ImageIO to use. If I 
> commented the phrase
>
> reader->SetImageIO(itk::JPEGImageIO::New());
>
> out, the error
>
>        “Could not create IO object for file E:\1340858885.jpg
>
>     Tried to create one of the following:
>
>     You probably failed to set a file suffix, or
>
>     set the suffix to an unsupported type.”
>
> occurred, but the program worked properly with the phrase mentioned above.
See my source code attached at the end of this mail.
>
>        Is there someone can tell me why this happened?
>
>
>
> Thanks a lot in advance!
>
>
>
> Wu, Pengfei
>
>
>
> Code:
>
> ________________________________
>
> int main(int argc, char* argv[])
>
> {
>
>     typedef itk::RGBPixel<unsigned short>  PixelType;
>
>     const unsigned int                     Dimension = 2;
>
>
>
>     typedef itk::Image<PixelType, Dimension>  ImageType;
>
>     typedef itk::ImageFileReader<ImageType>       ReaderType;
>
>
>
>     ReaderType::Pointer reader = ReaderType::New();
>
>
>
>     const char *filename = "E:\\1340858885.jpg";
>
>     //reader->SetImageIO(itk::JPEGImageIO::New());
>
>     reader->SetFileName(filename);
>
>     ImageType::Pointer image = reader->GetOutput();
>
>
>
>
>
>     typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
>
>     FilterType::Pointer connecter = FilterType::New();
>
>     connecter->SetInput(image);
>
>     vtkImageViewer *viewer = vtkImageViewer::New();
>
>     vtkRenderWindowInteractor *renderWindowInteractor = 
> vtkRenderWindowInteractor::New();
>
>     viewer->SetupInteractor(renderWindowInteractor);
>
>     viewer->SetInput(connecter->GetOutput());
>
>     viewer->Render();
>
>     viewer->SetColorWindow(255);
>
>     viewer->SetColorLevel(128);
>
>     renderWindowInteractor->Start();
>
>     cin.get();
>
>     return 0;
>
> }
>
> -------------------------------------End of 
> Code-------------------------------------------------------------
>
>
> _____________________________________
> 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.php
>
> 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
>
>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot 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.php
>
> 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
>



More information about the Insight-users mailing list