[Insight-users] Problems with ITK in MFC App

Kent Ogden ogdenk at upstate.edu
Thu Feb 23 11:48:43 EST 2012


Hi All,

I am trying to use ITK to register (non-rigidly) some mammographic images.  I have downloaded and compiled version 4 of ITK, and it compiles fine (compiled 32 bit version on a Win 7 64 bit system, using Visual Studio 2008).  I have been looking at the DeformableRegistration16 example, it runs fine when I pass it my two dicom file inputs and specify the outputs.  I have not yet assessed the quality of the registration, but visually it looks reasonably close for a first try.

My problems began when I tried to incorporate this example into a simple dialog based MFC program.  I learned quickly that unicode is a problem (once I could get a  compiled program) so I switched to multi-byte characters, that took care of some issues I had using CStrings.  I was first getting a compile error for the itkNewMacro( Self );  statement in the Command Observer classes:

error C2660: 'itk::LightObject::operator new' : function does not take 3 arguments

Not sure what to make of that, I don't see three arguments being passed in that Macro.  So, I took out the Command Observers to see if I could get it to compile at least.  Compilation finished, with only one warning:

1>c:\insighttoolkit-4.0.0\modules\io\imagebase\include\itkimagefilereader.hxx(440) : warning C4996: 'std::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\xutility(2550) : see declaration of 'std::copy'
1>        c:\insighttoolkit-4.0.0\modules\io\imagebase\include\itkimagefilereader.hxx(353) : while compiling class template member function 'void itk::ImageFileReader::GenerateData(void)'
1>        with
1>        [
1>            TOutputImage=ImageType
1>        ]
1>        c:\visual studio 2008\projects\registrationapp\registrationapp\registrationappdlg.cpp(327) : see reference to class template instantiation 'itk::ImageFileReader' being compiled
1>        with
1>        [
1>            TOutputImage=ImageType
1>        ]

The program would run, but would crash when the targetReader->Update(); was called for the first time.  I stepped into that to try to see where the error was occuring.  I saw that in itkImageFileReader.hxx the call to this->TestFileExistanceAndReadability(); executes without error, so it can see the file and open it.  However, the call to m_ImageIO = ImageIOFactory::CreateImageIO(this->GetFileName().c_str(), ImageIOFactory::ReadMode); fails, which I'm guess may be related to the compiler errors and warning noted above.  When I step into CreateImageIO, the second line is std::list< LightObject::Pointer > allobjects =
    ObjectFactoryBase::CreateAllInstance("itkImageIOBase");.  When this returns, allobjects is empty, which I'm guessing is a symptom of the problem.  Following this statement, there is a loop to iterate through the items in allobjects, but none of the statements in the loop executes since allobjects is empty.  I am using the exact same files as for the stand alone example, so I know that ITK can open these images.

I tried copying some of the preprocesser directives from the example (lots of ...._NO_DEPRECATE items there, thought that might be it) but there is no change in the behavior.  The big difference I see is that the example uses standard C libraries and I am using MFC in a shared DLL.
Maybe I  have some other compilation or link setting wrong in my application, can anyone offer any suggestions as to how to get around this?  I have used ITK (and VTK) in an MFC app several years ago (earlier versions of everything) with no problems like this, so maybe there is something different in Visual Studio 2008 vs 2005?  Thanks for any advice. 

Kent Ogden




********************************
Kent Ogden PhD
Associate Professor, Radiology
SUNY Upstate Medical University
750 E. Adams Street
Syracuse, NY  13210

email:  ogdenk at upstate.edu 
voice:  (315) 464-5083
fax:       (315) 464-2570
*********************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120223/064b8941/attachment.htm>


More information about the Insight-users mailing list