Page MenuHomePhabricator

Create AccessByItk macro which takes a pixel type list
Closed, ResolvedPublic

Description

Trying to fix T2072 revealed some issues with the AccessByItk macros provided in mitkImageAccessByItk.h .

1.) Some templates (ITK filter) can not be used with any primitive datatype in a meaningful way. With strict concept checking enabled in ITK, we would need a new macro which allows to specify a set of allowed pixel types in a mitk::Image.

2.) The error handling is inconsistent, when checking for pixel types and correct dimensions. Right now, specified dimensions are checked with "assert" (leading to inevitable program termination) and mitk::Image instances with non-matching pixel types trigger an output on the console (providing no means for users to check for errors).

I suggest the following:

ad 1.) Provide means to specify a list of allowed pixel types to be used in the multiplexing step.

ad 2.) Regard the calls to all AccessByItk macros as a contract on the allowed pixel types and dimensions and throw an exception in all cases where the mitk::Image does not comply with the allowed types, thus allowing users to correctly handle non-conforming image data.

Related Objects

StatusAssignedTask
ResolvedNone

Event Timeline

Please review branch bug-8492-accessbyitk-macro-with-typelist

Oops, the branch mentioned previously contains an unrelated commit.

Please review the new branch bug-8492-accessbyitk-macro-with-typelist-2 which also implements the suggested error handling.

I didn't compile it yet but looks good to me. More C++ magic than most people want to see :-)

I'll run a testcompile with our project on Linux. Did you already try it on the other platforms?

Only tested on Ubuntu 11.04 yet. I could run a test on Windodws 7 64 bit today.

Everything should be back-wards compatible, since I only touched the error handling for existing AccessByItk macros.

There is also a new unit test which (almost) all available macros (mitkAccessByItkTest).

Tested successfully on Windows 7 64bit, VS2008.

I changed the used technique from templates to using the C preprocessor. The template type list approach had some limitations. Please see the updated Specification page.

Everything compiles fine and all tests run on Ubuntu 11.04 and Windows 7 VS2008 (64bit).

Core modification flag pending...

[7fb25e]: Merge branch 'bug-8492-accessbyitk-macro-with-typelist-2'

  • bug-8492-

Merged commits:

2011-06-27 15:54:48 Sascha Zelzer [1ea8e9]
Improved macro documentation.


2011-06-27 15:53:04 Sascha Zelzer [ae6535]
Use the CMake configured define MITK_ACCESSBYITK_DIMENSIONS_SEQ.


2011-06-25 16:01:39 Sascha Zelzer [f1a3cd]
Added simple compile test for InstantiateAccessFunction macros.


2011-06-25 16:01:12 Sascha Zelzer [5bf13d]
Removed wrong export directive.


2011-06-25 16:00:47 Sascha Zelzer [b2ef3a]
Changed InstantiateAccessFunction macro style to match AccessByItk.


2011-06-25 15:59:43 Sascha Zelzer [aa4e88]
Much simplified by removing redundant code. Added configurable dimension.


2011-06-25 15:58:04 Sascha Zelzer [66a143]
Added additional CMake variable containing image dimensions.


2011-06-25 03:28:17 Sascha Zelzer [3ffd10]
Fixed AccessTwoImages macro


2011-06-24 20:07:04 Sascha Zelzer [257662]
Pass pixel type lists from supberbuild to MITK.


2011-06-24 20:06:43 Sascha Zelzer [d9d1e5]
Separate integral and floating pixel types into distinct variables.


2011-06-24 17:12:47 Sascha Zelzer [eb3b01]
Added documentation about passing arguments to AccessByItk_n


2011-06-24 16:55:13 Sascha Zelzer [563c1a]
Use the configured pixel types when accessing OpenCV images.


2011-06-24 16:54:26 Sascha Zelzer [5d0ff3]
Fixed Windows warnings.


2011-06-24 04:24:14 Sascha Zelzer [ed6129]
Windows compatibility for AccessByItk macros.

MSVC has crappy support for VA_ARGS expansion ant other
issues. Needed to drop variadic macros and use a tuple for
passing arguments. Further, custom MSVC variants for internal
macros are needed to cope with VC preprocessor issues.


2011-06-23 23:02:30 Sascha Zelzer [826e65]
Added missing headers due to restructuring in previous commit.


2011-06-23 23:00:13 Sascha Zelzer [6848bf]
Redesigned AccessByItk macros and cleaned up header files.

  • The AccessByItk macros use preprocessor magic now, instead of template magic. This is as flexible as the old style and as configurable as the previous type list approach.

    The macros are mostly backwards compatible, except for AccessFixedPixelTypeByItk and AccessFixedTypeByItk which take sequences of types and dimensions.

    Further, up to 25 arguments can now be passed to the access function with the same macro.
  • The CastToItkImage function template declaration has been moved to mitkImageCast.h and corresponding header files and include directives have been cleaned up.
  • Core classes have been reverted to use AccessByItk macros again (instead of the previous type list / functor approach).

2011-06-23 22:45:10 Sascha Zelzer [2152f3]
Added missing include guards and header files.


2011-06-23 22:44:14 Sascha Zelzer [69b796]
Added new macro for counting arguments.


2011-06-23 22:42:52 Sascha Zelzer [f3bf0b]
Make the AccessItkImageFunctor take a member function pointer.


2011-06-23 19:52:49 Sascha Zelzer [09f083]
Added headers to files.cmake.


2011-06-23 19:52:27 Sascha Zelzer [d5bd3c]
Added Boost Stringize header for preprocessing.


2011-06-22 21:05:17 Sascha Zelzer [2e8630]
Use include guards in mitkConfig.h


2011-06-22 21:05:07 Sascha Zelzer [59d40a]
New-style InstantiateAccessFunction macors, based on Boost PreProcessor.

These new macros allow for configurable type lists when instantiating
templates.


2011-06-22 21:02:40 Sascha Zelzer [7a9b86]
Added Boost preprocessor macros for handling variable type lists.


2011-06-22 01:26:23 Sascha Zelzer [7aaec6]
Use the new-style AccessByItk macros in RigidRegistration.


2011-06-22 01:25:00 Sascha Zelzer [554914]
Modified Core classes to use the new-style AccessByItk macros.

This allows to configure the template instantiations at compile time.


2011-06-22 01:23:40 Sascha Zelzer [d12f6a]
Added instantiate template macros for new-style AccessByItk functions.


2011-06-22 01:22:43 Sascha Zelzer [b5120d]
Removed unnecessary include directive.


2011-06-22 01:21:53 Sascha Zelzer [503c48]
Added AccessFixedDimensionDefaultPixelTypesByItk macros.


2011-06-22 01:20:14 Sascha Zelzer [19f890]
Reset to default values if pixel type list is empty.


2011-06-21 19:29:48 Sascha Zelzer [07a89f]
Use MITK_ACCESSBYITK_PIXEL_TYPES in MITK_MULTIPLEX_PICTYPE


2011-06-21 16:51:47 Sascha Zelzer [a93f7e]
AccessByItk improvements:

  • Renamed *Type* to *PixelType* for consistency
  • Added new AccessDefaultPixelTypesByItk which uses a CMake variable for the list of pixel types
  • Added try/catch block in documentation example code
  • Added deprecated keywords

2011-06-21 16:49:10 Sascha Zelzer [07c373]
Fixed typo in type name.


2011-06-12 14:58:47 Sascha Zelzer [97f6aa]
Fixed mitk::Image::ConstPointer case.


2011-06-12 14:23:27 Sascha Zelzer [9d10b6]
Throw a mitk::AccessByItkException object if AccessByItk fails.

Instead of using assert (which usually calls abort() and terminates the
program), this exceptions is now thrown consistently in case of a
mismatch in the pixel type or dimension of mitk::Image.


2011-06-11 19:17:01 Sascha Zelzer [588262]
Cleaned up some old documentation about AccessByItk macros.


2011-06-11 19:16:21 Sascha Zelzer [90e5bd]
Added assert statements about pixel types in AccessByItk macros.


2011-06-11 19:15:31 Sascha Zelzer [f3ff75]
Added typelist template and AccessSpecificTypesByItk macro.

[54e030]: Merge branch 'bug-8492-accessbyitk-macro-with-typelist-2'

  • bug-8492-

Merged commits:

2011-06-30 12:00:38 Sascha Zelzer [d6b8af]
Use the correct defines in InstantiateAccessFunction macros.