Skip to content

Commit 43ea92d

Browse files
authored
Merge pull request #5350 from N-Dekker/Fix-random-number-RGBGibbsPriorFilter
BUG: Fix random number in `RGBGibbsPriorFilter::GibbsTotalEnergy`
2 parents 68bcf62 + f74ec5d commit 43ea92d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ RGBGibbsPriorFilter<TInputImage, TClassifiedImage>::GibbsTotalEnergy(int i)
289289
if (changeflag)
290290
{
291291
difenergy = energy[label] - energy[1 - label];
292-
const double rand_num{ rand() / 32768.0 };
292+
const double rand_num{ rand() / (RAND_MAX + 1.0) };
293293
double energy_num{ std::exp(static_cast<double>(difenergy * 0.5 * size / (2 * size - m_Temp))) };
294294
if (rand_num < energy_num)
295295
{

0 commit comments

Comments
 (0)