<html>
<body>
<font size=3>Hi Daniel,<br><br>
I'm sorry, I did not subscribe to the developer list, only the user-list.
I just subscribed. You are right that a random generator should behave
the same on different platforms. The vnl_random would solve this problem
as well.<br>
btw: The boost-library also has a good source of
random-generators.<br><br>
Stefan.<br><br>
<br>
At 10:04 16/03/05, Blezek, Daniel J (Research) wrote:<br>
</font><blockquote type=cite class=cite cite><font face="arial" size=2 color="#0000FF">Stefan,
I started a thread on this a while ago relating to non-deterministic
behavior across platforms. If the ITK design committee approves the
move, it would be great to standardize the random number generator to be
sufficiently random, fast and generate the same sequences (from a given
seed) across platforms. The discussion culminated with Brad's post:
<a href="http://www.itk.org/mailman/private/insight-developers/2005-January/006220.html">http://www.itk.org/mailman/private/insight-developers/2005-January/006220.html</a>
I'm not sure any action happened on the
suggestions.</font><font size=3><br>
<br>
</font><font face="arial" size=2 color="#0000FF">As you point out, many
registration algorithms depend on random sampling, exactly where I came
across the problem.</font><font size=3><br>
<br>
</font><font face="arial" size=2 color="#0000FF">Cheers,</font><font size=3><br>
</font><font face="arial" size=2 color="#0000FF">-dan</font><font size=3><br>
</font>
<dl>
<dd><font face="tahoma" size=2>-----Original Message-----<br>
<dd>From:</b> insight-users-bounces@itk.org
[<a href="mailto:insight-users-bounces@itk.org" eudora="autourl">mailto:insight-users-bounces@itk.org</a>]On
Behalf Of </b>Stefan Klein<br>
<dd>Sent:</b> Wednesday, March 16, 2005 9:16 AM<br>
<dd>To:</b> Insight-users@itk.org<br>
<dd>Subject:</b> [Insight-users] random number generator<br><br>
</font><font size=3><br>
<dd>Dear itk-users,<br><br>
<dd>I did some tests with the underlying random generator of the
itkImageRandomIteratorWithIndex and it seems that, in Windows, it is 'not
very random'. <br><br>
<dd>The itkImageRandomIterator uses the following random-generator:<br>
<dd><ITKSOURCE>\Utilities\vxl\core\vnl\vnl_sample.<h/cxx><br><br>
<dd>In Linux the drand48 random-generator is used, which is a good
choice.<br>
<dd>In Windows however a "simple congruential random number
generator" is implemented, since drand48 is not available in
Windows. This gives inferior results, in my experience.<br><br>
<dd>To get a feel for the result look at the image1.<mhd/raw>,
which is in the file: randomtestresults.zip, which you can download from:
<a href="http://www.isi.uu.nl/People/Stefan/" eudora="autourl">http://www.isi.uu.nl/People/Stefan/</a><br>
<dd>The gray-values in this image show how many times a pixel was
sampled. The sampling<br>
<dd>process works was defined as follows:<br>
<dd> "An ImageRegionIterator walks N=200 times through
the image and tests<br>
<dd> at each voxel whether to sample it or not. The test is
performed by <br>
<dd> drawing a number between 0 and 1 using the random
generator defined in<br>
<dd> vnl_sample.h; a value >=0.5 means that the voxel is
sampled"<br>
<dd>As you can see in the image the pixels are not really selected at
random...<br><br>
<dd>If we use the itkImageRandomIteratorWithIndex to sample the image,
the result (image3.<mhd,raw>) may look better at first sight, but
the histogram looks terrible.<br><br>
<dd>On the internet I found the following link:<br>
<dd><a href="http://paine.wiau.man.ac.uk/pub/doc_vxl/core/vnl/html/classvnl__random.html" eudora="autourl">http://paine.wiau.man.ac.uk/pub/doc_vxl/core/vnl/html/classvnl__random.html</a><br>
<dd>It describes the files vnl_random.<h,cxx>; those files are not
included in the vxl-version that comes with ITK. I tried to use these as
a random generator. The results are now much better. Image2, which is
generated in the same was as image1, but with the random generator
defined in vnl_random, does not show any structure anymore. Image4, which
is generated using an ImageRandomIterator that uses the vnl_random as its
underlying random number generator, has the histogram that you would
expect.<br><br>
<dd>For more details please look at the source of the test program, which
you can also download from
<a href="http://www.isi.uu.nl/People/Stefan/" eudora="autourl">http://www.isi.uu.nl/People/Stefan/</a>
: itkrandomtestsource.zip. You may reproduce the results with this program. Note that only in Windows bad results will be obtained. In Linux there is no problem.<br><br>
<dd>Algorithms that rely on a good random generator may fail if you use the itkRandomImageIteratorWithIndex under Windows. For example, in my research on nonrigid registration I tried to use a stochastic gradient descent optimisation method for minimising the MattesMutualInformation in combination with a B-spline transform (it may speed up your registration algorithms; if you are interested: <br>
<dd><a href="http://www.isi.uu.nl/Research/Publications/publicationview.php?id=1011" eudora="autourl">http://www.isi.uu.nl/Research/Publications/publicationview.php?id=1011</a> ). When I used the itkImageRandomConstIteratorWithIndex for selecting spatial samples the registration results got significantly worse than when I used the itkImageMoreRandomConstIteratorWithIndex (which uses the vnl_random as underlying random number generator).<br><br>
<dd>Any comments on this would be appreciated!<br><br>
<dd>Stefan<br><br>
<br><br>
<br><br>
</font>
</dl></blockquote></body>
<br>
</html>