[Insight-developers] Insight Journal and ITK v4

David Doria daviddoria at gmail.com
Tue Dec 4 17:06:47 EST 2012


On Tue, Dec 4, 2012 at 4:45 PM, Tom Vercauteren <tom.vercauteren at m4x.org>
wrote:
> Hi folks,
>
> I unfortunately have almost no time anymore to contribute to ITK. Yet,
> I wanted to start fiddling with ITK 4 (I know it has been out for
> quite some time already...) by cleaning up an old submission of mine
> that needs some TLC to compile seamlessly with ITK 3 and 4:
> http://hdl.handle.net/1926/510
>
> I was happy to see that the code is now on github
>   https://github.com/midas-journal/midas-journal-154
> but I could not find anywhere in the Insight Journal documentation
> whether (and how) I could use this repository to update the
> submission.
>
> Then I started without any porting effort to compile my old code with
> ITK 4. I did not want to rely on any ITKv3Support mechanism as I
> didn't want my code not to be native ITK4 in the end (I still have bad
> memories about relying on Qt3Support a few years ago).
>
> I first stumbled into a compilation error in ImageCompare.cxx:
>   #error For ITKv4 compatibility, use
> itk::Testing::ComparisonImageFilter instead of
> itk::DifferenceImageFilter
>
> Remembering that ImageCompare was part of the Insight Journal template
> package, I went back and re-downloaded the template package.
> Unfortunately, the template package has not been ported to ITK4 yet
> and the ImageCompare.cxx file is still the same as the old one I had.
>
> I could of course patch my local Insight Journal Template Package as
> well as my other files and when everything will work fine, I could
> also upload a new source package to the Insight Journal rather than
> using github but this doesn't sound quite right. Did I miss something
> or is it simply that the Insight Journal also needs some TLC to
> properly handle ITK4?
>
> That being said, are there any suggestions to handle seamlessly ITK 3
> and 4 without imposition the use of ITKv3Support. I can see two
> options right now:
> 1) Pepper the code with #if ITK_VERSION
> 2) Have two distinct files, one for ITK3, one for ITK4 and let cmake
> choose which one to compile
>
> Sorry for the long email and thanks for all the efforts that have been
> made for ITK4 already.
>
> Tom

I fixed a few of these things a while ago:

1) The use of itkDifferenceImageFilter which has been replaced by
itkTestingComparisonImageFilter.
2) ::itk::OStringStream seems to now be simply std::ostringstream.
3) I used the ${ITK_LIBRARIES} variable in the CMakeLists.txt.).

I guess they still haven't been integrated. Perhaps since it is an open
access journal, things like this template tarball should also be made
publicly fixable (through Gerrit of course) so that they can be kept up to
date by the community even if there is no funding.

I'll let someone else handle your question about easily supporting ITK3/4 :)

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20121204/f0f6bc7e/attachment.htm>
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)

INCLUDE(${CMAKE_SOURCE_DIR}/IJMacros.txt)

#Change PROJECT_NAME to the name of your project
PROJECT(ImageCopy)

#The following lines are required to use Dart
ENABLE_TESTING()
INCLUDE(Dart)

#Declare any external dependencies that your project may have here.
#examples include: ITK, VTK, JPEG, PNG, OpenGL, ZLIB, Perl, Java
#If you're not sure what name to use, look in the Modules directory of your
#cmake install and check that a file named Find(Package).cmake exists
#
# The packages can be specified with a version number, for example:
#
# ITK 2.8.1
# ITK 3.2.0
#
# If no version is specified, the most recent release of the package
# will be used.
SET(Required_Packages
ITK
)

#this foreach loads all of the packages that you specified as required.
#It shouldn't need to be modified.
FOREACH(Package ${Required_Packages})
  LOADPACKAGE(${Package})
ENDFOREACH(Package)

#Set any libraries that your project depends on.
#examples: ITKCommon, VTKRendering, etc
SET(Libraries
${ITK_LIBRARIES}
)

#the following block of code is an example of how to build an executable in
#cmake.  Unmodified, it will add an executable called "MyExe" to the project.
#MyExe will be built using the files MyClass.h and MyClass.cxx, and it will
#be linked to all the libraries you specified above.
#You can build more than one executable per project
SET(CurrentExe "ImageCompare")
ADD_EXECUTABLE(${CurrentExe} ImageCompare.cxx)
TARGET_LINK_LIBRARIES(${CurrentExe} ${Libraries})
SET(CurrentExe "ImageCopy")
ADD_EXECUTABLE(${CurrentExe} ImageCopy.cxx)
TARGET_LINK_LIBRARIES(${CurrentExe} ${Libraries})

#the following line is an example of how to add a test to your project.
#Testname is the title for this particular test.  ExecutableToRun is the
#program which will be running this test.  It can either be a part of this
#project or an external executable.  After that list any args that are needed
#for this test.  Include as many tests as you like.  If your project doesn't have
#any tests you can comment out or delete the following line.
ADD_TEST(CreateImage ImageCopy ${CMAKE_SOURCE_DIR}/img1.png)
ADD_TEST(CompareImage ImageCompare ${CMAKE_SOURCE_DIR}/img1.png ${CMAKE_SOURCE_DIR}/img1.png.base.png)

#Once you're done modifying this template, you should rename it to "CMakeLists.txt"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageCompare.cxx
Type: application/octet-stream
Size: 8197 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20121204/f0f6bc7e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageCopy.cxx
Type: application/octet-stream
Size: 1447 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20121204/f0f6bc7e/attachment-0001.obj>


More information about the Insight-developers mailing list