Skip to content

Commit 663e0cb

Browse files
committed
ENH: Initialize all arrays in LabelSetUtils.h file
Initialize all arrays in `LabelSetUtils.h` file.
1 parent 420c9f7 commit 663e0cb

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

include/itkLabelSetUtils.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ doOneDimensionErodeFirstPass(TInIter & inputIterator,
257257
// const RealType magnitude = (magnitudeSign * iscale * iscale)/(2.0 *
258258
// sigma);
259259
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
260-
LineBufferType lineBuf(lineLength);
261-
LabelBufferType labBuf(lineLength);
260+
LineBufferType lineBuf(lineLength, 0.0);
261+
LabelBufferType labBuf(lineLength, 0.0);
262262

263263
inputIterator.SetDirection(direction);
264264
outputIterator.SetDirection(direction);
@@ -393,11 +393,13 @@ doOneDimensionDilateFirstPass(TInIter & inputIterator,
393393
// restructure equation to reduce numerical error
394394
// const RealType magnitude = (magnitudeSign * iscale * iscale)/(2.0 *
395395
// 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);
396+
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0);
397+
const RealType initRealValue = 0.0;
398+
const typename TInIter::PixelType initPixelValue = 0.0;
399+
LineBufferType lineBuf(lineLength, initRealValue);
400+
LabelBufferType labBuf(lineLength, initPixelValue);
401+
LineBufferType tmpLineBuf(lineLength, initRealValue);
402+
LabelBufferType newLabBuf(lineLength, initPixelValue);
401403

402404
inputIterator.SetDirection(direction);
403405
outputIterator.SetDirection(direction);
@@ -476,8 +478,8 @@ doOneDimensionErode(TInIter & inputIterator,
476478
iscale = imageScale;
477479
}
478480
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0 * sigma);
479-
LineBufferType lineBuf(lineLength);
480-
LabelBufferType labBuf(lineLength);
481+
LineBufferType lineBuf(lineLength, 0.0);
482+
LabelBufferType labBuf(lineLength, 0.0);
481483

482484
inputIterator.SetDirection(direction);
483485
outputDistIterator.SetDirection(direction);
@@ -618,11 +620,12 @@ doOneDimensionDilate(TInIter & inputIterator,
618620
// restructure equation to reduce numerical error
619621
const RealType magnitude = (magnitudeSign * iscale * iscale) / (2.0 * sigma);
620622
// 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);
623+
const RealType initRealValue = 0.0;
624+
const typename TInIter::PixelType initPixelValue = 0.0;
625+
LineBufferType lineBuf(lineLength, initRealValue);
626+
LabelBufferType labBuf(lineLength, initPixelValue);
627+
LineBufferType tmpLineBuf(lineLength, initRealValue);
628+
LabelBufferType newLabBuf(lineLength, initPixelValue);
626629

627630
inputIterator.SetDirection(direction);
628631
inputDistIterator.SetDirection(direction);

0 commit comments

Comments
 (0)