ENH: Improved writing speed for TIFF images

Previously, in itkTIFFImageIO.cxx rowsperstrip was set to a default
value so that it would be calculated using the STRIP_SIZE_DEFAULT
defined to be 8 kB in tiffiop.h. However, this a very conservative
small number, and it leads to very small strips resulting in many io
operations, which can be slow when written over networks that require
encryption/decryption of each packet (such as sshfs). Conversely, if
the value is too high, a lot of extra memory is required to store the
strips before they are written out. Experiments writing TIFF images to
drives mapped by sshfs showed that a good tradeoff is achieved when
the STRIP_SIZE_DEFAULT is increased to 1 MB. Rather than change that
value in the third party libtiff library, we instead compute the
rowsperstrip in itkTIFFImageIO.cxx to lead to this same value.

This results in an increase in memory usage but no increase in writing
time when writing locally and significant writing time improvement
when writing over sshfs.  For example, writing a 2048x2048 uint16
image with 8 kB per strip leads to 2 rows per strip and takes about
120 seconds writing over sshfs. Using 1 MB per strip leads to 256 rows
per strip, which takes only 4 seconds to write over sshfs.

This has no effect on accuracy, only writing time.  All of the tests
still pass.

Change-Id: Id3a99fbcbcd430e6436dbf262aab2fc70b82937a
PERF: fix cppcheck issues in itk::ImageRegion

[Modules/Core/Common/include/itkImageRegion.h:184]: (performance) Variable 'same' is reassigned a value before the old one has been used.
[Modules/Core/Common/include/itkImageRegion.h:195]: (performance) Variable 'same' is reassigned a value before the old one has been used.

Change-Id: Ib03a09a37e92216d8a7ed05891eb2a5bd578858d
STYLE: fix cppcheck style warning

[Modules/Core/Common/include/itkNeighborhoodOperator.hxx:45]: (style) The scope of the variable 'swap_with' can be reduced.

Change-Id: I98f8ab8dde19b8107c3d08ad91c1d2b855fe529a
BUG: fix out of bounds access of array

address 3 coverity issues related to accessing m_Visitors out of
bounds.

CID 1081041 (#4-1 of 4): Out-of-bounds read (OVERRUN)
3. overrun-local: Overrunning array of 9 8-byte elements at element
index 9 (byte offset 72) by dereferencing pointer "&this->m_Visitors[id]"

Change-Id: Idf7e306c489a30e429ceff74d61849d5bbdb664f
DOC: Better description of what the code is doing.

Improved the code organization and variables names in order to better convey
the actions that the code is taken. This was driven by a warning reported by
a Coverity scan with text:

  1103094 Out-of-bounds access
  Memory not owned by this buffer will be accessed, causing memory corruption
  or incorrect computations.

  In

      itk::​Functor::​ScalarToRGBPixelFunctor<unsigned char>::
      ​operator ()(unsigned char const&):

  Access of memory past the end of a memory buffer

The scan warns about the risk of using out of bounds elements due to the use
of an array/pointer to navigate through the bytes of the scalar class. This
is however, the correct intent of the code, and bounds are checked properly
using the sizeof() the scalar type.

Change-Id: I1884ca33f5a7eea8bb28b043f8bcef4bff129805
COMP: Destination buffer too small

CID 1103098 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)
buffer_size_warning: Calling strncpy with a maximum size argument of
2049 bytes on destination array "curImage->filename" of size 2049
bytes might leave the destination string unterminated.

Change-Id: I2ed96404b9b2374a84406d6ea3d46b70006ae6a5
COMP: Destination buffer too small

CID 1103199 (#1 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 35 byte destination string
"hdr->hospital" by writing 2049 bytes from "tmpStr"

CID 1103199 (#2 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->scanId" by writing 2049 bytes from "tmpStr".

CID 1103199 (#3 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->patientId" by writing 2049 bytes from "tmpStr".

CID 1103199 (#4 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->date" by writing 2049 bytes from "tmpStr".

In all cases, strcpy was replaced with strncpy.

Change-Id: I9955d3c34970b89dfddaa233dfbcb8943166f1be
STYLE: fix cppcheck errors

[Modules/Core/Common/include/itkAnnulusOperator.hxx:107]: (style) The scope of the variable 'inInner' can be reduced.
[Modules/Core/Common/include/itkAnnulusOperator.hxx:107]: (style) The scope of the variable 'inOuter' can be reduced.

Change-Id: Ie604468f2d33a200c86b1bfc1b4a730b4525c6a3
BUG: Memory leak. Reported by Coverity.

It was missing to call delete on an allocated array.

It was reported by Coverity as:

    1081112 Resource leak

    The system resource will not be reclaimed and reused, reducing the future
    availability of the resource.

    In itk::​MeshIOBase::​WriteBufferAsBinary<…>(T2 *,
     std::​basic_ofstream<char, std::​char_traits<char>> &, unsigned long):
     Leak of memory or pointers to system resources.

Change-Id: I0822f7332a203a7cdd89b72de2365c67189feabc
BUG: Resource leak

CID 1106766: Resource leak (RESOURCE_LEAK)
overwrite_var: Overwriting "cinfo" in "cinfo =
opj_create_compress(CODEC_JPT)" leaks the storage that "cinfo" points
to.

CID 1106766: Resource leak (RESOURCE_LEAK)
overwrite_var: Overwriting "cinfo" in "cinfo =
opj_create_compress(CODEC_JP2)" leaks the storage that "cinfo" points
to.

Change-Id: I030a5fa5455a64251423399714c9e0796c799242
COMP: Resource leak

CID 1103190: Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "mySceneChildren" going out of scope leaks
the storage it points to.

Added a delete mySceneChidren before each return EXIT_FAILURE

Change-Id: I5a0a46dbe1034da65727dac69b9b9244371c689a
COMP: Big parameter passed by value

CID 1125947 Copying large values is inefficient, consider passing by
reference; size thresholds for detection can be adjusted.

In ComputeAreaError<…>(T1, unsigned int): A large function call
parameter or exception catch statement is passed by value

Change-Id: I813f55c9531d14d208dc5bc3b33d425d3121a92a
Merge topic 'coverity_cid_1081041_53_57'

6149847 BUG: fix out of bounds access of array
Merge topic 'Coverity_itkJPEG2000ImageIO'

387b74d BUG: Resource leak
Merge topic 'Coverity_itkGE4ImageIO'

3d5ddd0 COMP: Destination buffer too small
Merge topic 'coverity_cid_1103094_out_of_bounds_access'

19e43d4 DOC: Better description of what the code is doing.
Merge topic 'Coverity_itkGE5ImageIO'

550f6ff COMP: Destination buffer too small
Merge topic 'Coverity_itkReadWriteSpatialObjectTest'

358e443 COMP: Resource leak
Merge topic 'Coverity_itkFlatStructuringElementTest'

f68a325 COMP: Big parameter passed by value
Merge topic 'coverity_cid_1081112_resource_leak_p2'

8456bb9 BUG: Memory leak. Reported by Coverity.