File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
Modules/Core/Common/include Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -64,20 +64,15 @@ ImageRandomConstIteratorWithIndex<TImage>::RandomJump()
64
64
{
65
65
using PositionValueType = IndexValueType;
66
66
67
- const PositionValueType randomPosition = static_cast <PositionValueType>(
67
+ auto position = static_cast <PositionValueType>(
68
68
m_Generator->GetVariateWithOpenRange (static_cast <double >(m_NumberOfPixelsInRegion) - 0.5 ));
69
- /*
70
- vnl_sample_uniform(0.0f,
71
- static_cast<double>(m_NumberOfPixelsInRegion)-0.5) );
72
- */
73
69
74
- PositionValueType position = randomPosition;
75
- PositionValueType residual;
70
+ const SizeType regionSize = this ->m_Region .GetSize ();
76
71
77
72
for (unsigned int dim = 0 ; dim < TImage::ImageDimension; ++dim)
78
73
{
79
- const SizeValueType sizeInThisDimension = this -> m_Region . GetSize () [dim];
80
- residual = position % sizeInThisDimension;
74
+ const SizeValueType sizeInThisDimension = regionSize [dim];
75
+ const PositionValueType residual = position % sizeInThisDimension;
81
76
this ->m_PositionIndex [dim] = residual + this ->m_BeginIndex [dim];
82
77
position -= residual;
83
78
position /= sizeInThisDimension;
Original file line number Diff line number Diff line change @@ -63,15 +63,15 @@ ImageRandomConstIteratorWithOnlyIndex<TImage>::RandomJump()
63
63
{
64
64
using PositionValueType = IndexValueType;
65
65
66
- const PositionValueType randomPosition = static_cast <PositionValueType>(
66
+ auto position = static_cast <PositionValueType>(
67
67
m_Generator->GetVariateWithOpenRange (static_cast <double >(m_NumberOfPixelsInRegion) - 0.5 ));
68
- PositionValueType position = randomPosition;
69
- PositionValueType residual ;
68
+
69
+ const SizeType regionSize = this -> m_Region . GetSize () ;
70
70
71
71
for (unsigned int dim = 0 ; dim < TImage::ImageDimension; ++dim)
72
72
{
73
- const SizeValueType sizeInThisDimension = this -> m_Region . GetSize () [dim];
74
- residual = position % sizeInThisDimension;
73
+ const SizeValueType sizeInThisDimension = regionSize [dim];
74
+ const PositionValueType residual = position % sizeInThisDimension;
75
75
this ->m_PositionIndex [dim] = residual + this ->m_BeginIndex [dim];
76
76
position -= residual;
77
77
position /= sizeInThisDimension;
You can’t perform that action at this time.
0 commit comments