BUG: LabelGeometry cropped images with non-unit spacing incorrectly

The itkLabelGeometryImageFilter previously cropped object images
incorrectly when the input image had non-unit spacing.  This was
corrected by simply including spacing in the resampler.  This patch
also includes a rewritten test that is simpler and clearer.  The test
now includes image regression tests.  It also includes feature values
regression tests by writing and reading the features values as CSV
files.  It tests both 2D images and 3D volumes.

Change-Id: I6767489993b30c187ae41b3a6c904bc3dd68d67e
COMP: Fix ambiguous specialization of GDCM Element

To disable certain combinations of template arguments to GDCM's
Element class, ambiguous declarations where added with no
definition. These combintations are causing compilations warnings such
as:

gdcmElement.h(611): warning #889: this partial specialization would
have made the instantiation of class "gdcm::Element<4096, 218367>"
ambiguous
  template <int TVM> class Element<VR::OB, TVM>;

While simply removing ambiguous declarations, would remove the
warnings this would not preserve the authors original intent to
prevent instantiation. To achieve a additional class was added with a
concept like check, to prevent instantiation.

Change-Id: I01c7d3f663a2e97804a465fb460d964542c6bf2d
COMP: OpenJPEG #ifdef WIN32 not reliable ITK-3101.

It appears that in Modules/ThirdParty/OpenJEPEG/src/openjpeg/opj_malloc.h in
line 67 the '#ifdef WIN32' results in 0 on my system, Vista x64, VS9. As a
result the linker expects posix_memalign. This causes multiple build errors.

Suggested-by: Constantine Zakkaroff <mnkz@leeds.ac.uk>

Prefer to use the _WIN32 preprocessor definition defined intrinsically by the
compiler as opposed to "WIN32" defined by the SDKs.

Change-Id: Idd94085cdad4fccd302deef57975c305d3c85d22
BUG: enable return value optimzation for VS debug mode

The GetPixel methods require return value optimization to disable a
copy constructor so that the return and used VariableLengthVectors are
internally a reference to the VectorImage's data.

This patch resolve outstanding Interpolator test failures on Visual
Studio debug builds.

Change-Id: I188f589abdcbb230a8217f8850550b6bd50aceed
ENH: Converting itk::Point, Size, Index, Vector, Matrix to corresponding OpenCV data structure

Change-Id: If24a8a7b15c41490e61a6b0c16e0d5067c286755
Merge topic 'ITKOpenCVConversion'

c7a58c7 ENH: Converting itk::Point, Size, Index, Vector, Matrix to corresponding OpenCV data structure
BUG: increase the image tolerance for deformable test 5

Change-Id: I8d0667e05ad8a7741b43cad3aa9792660049ba56
Merge branch 'WIN32def' into release
Merge branch 'release'
Merge topic 'VectorImageGetPixelReturnValueOptimization'

38a2f1a BUG: enable return value optimzation for VS debug mode
BUG: ProgressAccumulator reports incorrectly for streamed filters

This patch addresses a limitation in the ProgressAccumulator
mini-pipeline functionality that does not enable correct progress
reporting when filters are processed using the
itkStreamingImageFilter. The progress information is incorrect because
each filter in the mini-pipeline is executed multiple times for
different regions, but the overall progress is not captured and
stored. Instead, the ProgressAccumulator only reports the sum of the
current progress of each filter in the mini-pipeline ignoring previous
progress of each filter. For example, the progress of
itkDiscreteGaussianImage does not increase monotonically and does not
reach a final progress of 1. In fact, the final progress value it
reaches depends on the number of streams that are used.

This has now been fixed by including a starting event observer that
adds the progress of the filter to the accumulated progress before
resetting the filter's progress to 0 for the next run. This is
especially helpful when streaming is used since the filter is
restarted multiple times for different regions of the input. By
capturing the start event, it is no longer necessary for filters that
use the ProgressAccumulator to explicitly call
ResetFilterProgressAndKeepAccumulatedProgress() as is done, for
example, in itkLaplacianRecursiveGaussianImageFilter and
itkGradientRecursiveGaussianImageFilter. In fact, that method is no
longer needed and has been marked as deprecated.
Thus, this patch also
simplifies the use of the ProgressAccumulator.
Also, when that method was called, it caused the
filters to re-run even if they have not changed.  This is because a
call to SetProgress(0) is made on every filter inside of the
ResetFilterProgressAndKeepAccumulatedProgress() method.
Thus this patch enables filters not to re-run unless they
have to, which will lead to time savings in some cases.

The method ResetProgress has been deprecated because it served no
purpose.  This functionality has been moved to the constructor where
it belongs.

Because ResetProgress and
ResetFilterProgressAndKeepAccumulatedProgress were deprecated, all
calls to these methods in other ITK filters have been removed after
verifying their correctness.
The tests of those filters have also been updated to include a call to
itkSimpleFilterWatcher to write out the filter progress.

This addresses the problem that was described in
http://www.itk.org/Bug/print_bug_page.php?bug_id=9887 and
https://itk.icts.uiowa.edu/jira/browse/ITK-3047

An example output of running DiscreteGaussianImageFilter on a 2D image
with 4 streams before and after this change are as follows:

Before:
| 0 | 0.0111111 | 0.0222222 | 0.0333333 | 0.0444444 | 0.0555556 |
0.0666667 | 0.0777778 | 0.0888889 | 0.1
| 0.111111 | 0.111111 | 0.111111 | 0.122222 | 0.133333 | 0.144444 |
0.155556 | 0.166667 | 0.177778 | 0.188889
| 0.2 | 0.211111 | 0.222222 | 0.222222 | 0.222222 | 0.111111 |
0.122222 | 0.133333 | 0.144444 | 0.155556
| 0.166667 | 0.177778 | 0.188889 | 0.2 | 0.211111 | 0.222222 |
0.222222 | 0.111111 | 0.122222 | 0.133333
| 0.144444 | 0.155556 | 0.166667 | 0.177778 | 0.188889 | 0.2 |
0.211111 | 0.222222 | 0.222222 | 0.25
| 0.138889 | 0.15 | 0.161111 | 0.172222 | 0.183333 | 0.194444 |
0.205556 | 0.216667 | 0.227778 | 0.238889
| 0.25 | 0.25 | 0.138889 | 0.15 | 0.161111 | 0.172222 | 0.183333 |
0.194444 | 0.205556 | 0.216667
| 0.227778 | 0.238889 | 0.25 | 0.25 | 0.277778 | 0.166667 | 0.177778 |
0.188889 | 0.2 | 0.211111
| 0.222222 | 0.233333 | 0.244444 | 0.255556 | 0.266667 | 0.277778 |
0.277778 | 0.166667 | 0.177778 | 0.188889
| 0.2 | 0.211111 | 0.222222 | 0.233333 | 0.244444 | 0.255556 |
0.266667 | 0.277778 | 0.277778 | 0.305556
| 0.333333

After:
| 0 | 0.0111111 | 0.0222222 | 0.0333333 | 0.0444444 | 0.0555556 |
0.0666667 | 0.0777778 | 0.0888889 | 0.1
| 0.111111 | 0.111111 | 0.111111 | 0.122222 | 0.133333 | 0.144444 |
0.155556 | 0.166667 | 0.177778 | 0.188889
| 0.2 | 0.211111 | 0.222222 | 0.222222 | 0.222222 | 0.222222 |
0.233333 | 0.244444 | 0.255556 | 0.266667
| 0.277778 | 0.288889 | 0.3 | 0.311111 | 0.322222 | 0.333333 |
0.333333 | 0.333333 | 0.344444 | 0.355556
| 0.366667 | 0.377778 | 0.388889 | 0.4 | 0.411111 | 0.422222 |
0.433333 | 0.444444 | 0.444444 | 0.472222
| 0.472222 | 0.483333 | 0.494444 | 0.505556 | 0.516667 | 0.527778 |
0.538889 | 0.55 | 0.561111 | 0.572222
| 0.583333 | 0.583333 | 0.583333 | 0.594445 | 0.605556 | 0.616667 |
0.627778 | 0.638889 | 0.65 | 0.661111
| 0.672222 | 0.683333 | 0.694444 | 0.694444 | 0.722222 | 0.722222 |
0.733333 | 0.744444 | 0.755556 | 0.766667
| 0.777778 | 0.788889 | 0.8 | 0.811111 | 0.822222 | 0.833333 |
0.833333 | 0.833333 | 0.844445 | 0.855556
| 0.866667 | 0.877778 | 0.888889 | 0.9 | 0.911111 | 0.922222 |
0.933333 | 0.944444 | 0.944444 | 0.972222
| 1

Change-Id: Idf71bb6a1ea401f7c91149dce56f847dd5dfc15d
Merge topic 'DeformableTest5Tolerance'

861c0f9 BUG: increase the image tolerance for deformable test 5
BUG: fix gradient recusive gaussian in VS debug

This is another case there we are relying on return value optimization
with VectorImages.

Change-Id: I6d8d84939b80a6d82a255b75e105fe6dd0395705
Merge topic 'ProgressAccumulator'

8e2fb60 BUG: ProgressAccumulator reports incorrectly for streamed filters
Merge topic 'LabelGeometryImageFilter'

f2052c8 BUG: LabelGeometry cropped images with non-unit spacing incorrectly
Merge topic 'FixVectorImageGradientRecursiveGaussianRVO'

6a60327 BUG: fix gradient recusive gaussian in VS debug
BUG: in NthElementAdaptor pass by reference to modify argument

Change-Id: I54d9b264216857ebd3b2ba7ac6d302e9ebdd56f8
Merge topic 'FixVectorImageGradientRecursiveGaussianRVO'

941f550 BUG: in NthElementAdaptor pass by reference to modify argument
BUG: LabelGeometry matrix difference tolerance

This patch relaxes the tolerance used to compare matrices so that the
tests will pass on very different OS versions.  It also corrects a
minor bug of default values causing compiler errors on some OS
versions.

Change-Id: I0866ec3597e7abafb418f3329a00bac8ca6be371
Merge topic 'LabelGeometryTolerance'

c3a6fb4 BUG: LabelGeometry matrix difference tolerance