Skip to content

Commit 2506727

Browse files
authored
Merge pull request #48 from jhlegarreta/InitializeAllArrays
ENH: Initialize all arrays in `LabelSetUtils.h` file
2 parents 2437c09 + 108b0ba commit 2506727

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

include/itkLabelSetUtils.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ doOneDimensionErodeFirstPass(TInIter & inputIterator,
256256
// restructure equation to reduce numerical error
257257
// const RealType magnitude = (magnitudeSign * iscale * iscale)/(2.0 *
258258
// sigma);
259-
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
260-
LineBufferType lineBuf(lineLength, 0.0);
261-
LabelBufferType labBuf(lineLength);
259+
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
260+
const typename TInIter::PixelType initPixelValue = 0.0;
261+
LineBufferType lineBuf(lineLength, 0.0);
262+
LabelBufferType labBuf(lineLength, 0.0);
262263

263264
inputIterator.SetDirection(direction);
264265
outputIterator.SetDirection(direction);
@@ -393,11 +394,13 @@ doOneDimensionDilateFirstPass(TInIter & inputIterator,
393394
// restructure equation to reduce numerical error
394395
// const RealType magnitude = (magnitudeSign * iscale * iscale)/(2.0 *
395396
// sigma);
396-
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
397-
LineBufferType lineBuf(lineLength);
398-
LabelBufferType labBuf(lineLength);
399-
LineBufferType tmpLineBuf(lineLength);
400-
LabelBufferType newLabBuf(lineLength);
397+
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
398+
const RealType initRealValue = 0.0;
399+
const typename TInIter::PixelType initPixelValue = 0.0;
400+
LineBufferType lineBuf(lineLength, initRealValue);
401+
LabelBufferType labBuf(lineLength, initPixelValue);
402+
LineBufferType tmpLineBuf(lineLength, initRealValue);
403+
LabelBufferType newLabBuf(lineLength, initPixelValue);
401404

402405
inputIterator.SetDirection(direction);
403406
outputIterator.SetDirection(direction);
@@ -476,8 +479,8 @@ doOneDimensionErode(TInIter & inputIterator,
476479
iscale = imageScale;
477480
}
478481
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0 * sigma);
479-
LineBufferType lineBuf(lineLength);
480-
LabelBufferType labBuf(lineLength);
482+
LineBufferType lineBuf(lineLength, 0.0);
483+
LabelBufferType labBuf(lineLength, 0.0);
481484

482485
inputIterator.SetDirection(direction);
483486
outputDistIterator.SetDirection(direction);
@@ -618,11 +621,13 @@ doOneDimensionDilate(TInIter & inputIterator,
618621
// restructure equation to reduce numerical error
619622
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0 * sigma);
620623
// const RealType magnitude = (magnitudeSign * iscale * iscale)/(2.0 );
621-
LineBufferType lineBuf(lineLength);
622-
LabelBufferType labBuf(lineLength);
623-
LineBufferType tmpLineBuf(lineLength);
624-
LabelBufferType newLabBuf(lineLength);
625-
LabelBufferType tmpLabBuf(lineLength);
624+
const RealType initRealValue = 0.0;
625+
const typename TInIter::PixelType initPixelValue = 0.0;
626+
LineBufferType lineBuf(lineLength, initRealValue);
627+
LabelBufferType labBuf(lineLength, initPixelValue);
628+
LineBufferType tmpLineBuf(lineLength, initRealValue);
629+
LabelBufferType newLabBuf(lineLength, initPixelValue);
630+
LabelBufferType tmpLabBuf(lineLength, initPixelValue);
626631

627632
inputIterator.SetDirection(direction);
628633
inputDistIterator.SetDirection(direction);

0 commit comments

Comments
 (0)