<div dir="ltr">Good call, with threadId as a seed, it works with multiple threads.<div><br></div><div>Thank you very much.</div><div>-Laurent</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 6, 2014 at 5:00 PM, Wok <span dir="ltr"><<a href="mailto:wokitk@gmail.com" target="_blank">wokitk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">> I noticed that the gaussian filter does not call Initialize of the NormalVariateGenerator, but I tried to add it, and it doesn't make any difference.<br>
<br>
</div>As mentioned before, the thing is you can input a seed to Initialize.<br>
> void itk::Statistics::NormalVariateGenerator::Initialize ( int randomSeed)<br>
<br>
If your assumption about the threads is correct, I would fix the bug<br>
by modifying:<br>
> <a href="https://github.com/midas-journal/midas-journal-721/blob/master/noise/itkAdditiveGaussianNoiseImageFilter.txx" target="_blank">https://github.com/midas-journal/midas-journal-721/blob/master/noise/itkAdditiveGaussianNoiseImageFilter.txx</a><br>
<br>
so that Initialize is called with threadId.<br>
> template <class TInputImage, class TOutputImage> void AdditiveGaussianNoiseImageFilter<TInputImage, TOutputImage><br>
::ThreadedGenerateData( const OutputImageRegionType<br>
&outputRegionForThread, int threadId)<br>
<br>
Best,<br>
<br>
Wok<br>
<br>
2014-03-06 22:40 GMT+01:00 Laurent Chauvin <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>>:<br>
<div class="HOEnZb"><div class="h5">> Do you mean ask the user to input a number (always different) for each<br>
> thread ?<br>
><br>
> Thank you.<br>
> -Laurent<br>
><br>
><br>
> On Thu, Mar 6, 2014 at 4:32 PM, Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>><br>
> wrote:<br>
>><br>
>> I haven't looked at the classes closely. But would expect these filters<br>
>> have a user settable seed, to make the results reproduce able, and be the<br>
>> same independent with the number of threads.<br>
>><br>
>> The trick would be to have each thread has a random number generator<br>
>> object, then at the beginning of each line seed it with a combination of the<br>
>> user defined seed, and the starting index of the scan-line ( perhaps<br>
>> multiplied by a prime number).<br>
>><br>
>> Hope that some help... I just have some ideas in my head about some ways<br>
>> to do it...<br>
>><br>
>> Brad<br>
>><br>
>> On Mar 6, 2014, at 4:26 PM, Laurent Chauvin <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>><br>
>> wrote:<br>
>><br>
>> It actually works but you have to force the filter to only use 1 thread.<br>
>><br>
>> I think otherwise all threads got the same "random" values, which generate<br>
>> same output for all threads.<br>
>> My guess is the image is divided in 'lines' or 'column', each of them<br>
>> managed by a separated thread. If all threads have same random values, then<br>
>> the output will be patterned.<br>
>><br>
>> If it's possible to have different random values for each threads, then it<br>
>> should be possible to run it with multiple threads.<br>
>> I think one possibility would be to use a timestamp as seed for the<br>
>> NormalVariateGenerator filter.<br>
>> I tried with GetTimeStamp(), but this is the same timestamp for all<br>
>> threads.<br>
>> I tried with GetNumberOfThreads(), but still the same number for all<br>
>> threads.<br>
>> I tried with GetMTime(), same.<br>
>> I tried with 'this', but this is the same pointer too.<br>
>><br>
>> I'm not sure which variable could be different in each thread.<br>
>><br>
>> Thank you.<br>
>> -Laurent<br>
>><br>
>><br>
>> On Thu, Mar 6, 2014 at 3:56 PM, Laurent Chauvin <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>><br>
>> wrote:<br>
>>><br>
>>> I tried to use the itkAdditiveGaussianNoiseFilter, but on the output<br>
>>> image I obtain, the noise seems really patterned.<br>
>>><br>
>>> I compiled the code from the article, and run exactly the same example<br>
>>> with same parameters and I don't have the same results as on the article.<br>
>>> As I mentionned, the noise I obtain seems really patterned.<br>
>>><br>
>>> I enclosed the picture I obtain after running the 'gauss' example with<br>
>>> the same parameters as the article.<br>
>>><br>
>>> Is it possible that the 'NormalVariateGenerator' used in the<br>
>>> AdditiveGaussianNoiseFilter changed since the article has been written ?<br>
>>> I noticed that the gaussian filter does not call Initialize of the<br>
>>> NormalVariateGenerator, but I tried to add it, and it doesn't make any<br>
>>> difference.<br>
>>><br>
>>> Thank you.<br>
>>> -Laurent<br>
>>><br>
>>><br>
>>> On Thu, Mar 6, 2014 at 1:19 PM, Laurent Chauvin<br>
>>> <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>> wrote:<br>
>>>><br>
>>>> I didn't look in the article for now.<br>
>>>><br>
>>>> I was first trying to compile the code. There is a minor modification to<br>
>>>> do to be compatible with ITKv4, but otherwise it's pretty straight forward.<br>
>>>> So far I only tested itkAdditiveGaussianNoiseFilter.<br>
>>>><br>
>>>> Thank you.<br>
>>>> -Laurent<br>
>>>><br>
>>>><br>
>>>> On Thu, Mar 6, 2014 at 1:11 PM, Bradley Lowekamp<br>
>>>> <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>> wrote:<br>
>>>>><br>
>>>>> It would be great if you could to a brief review of the IJ article to<br>
>>>>> facilitate integrating it into ITK.<br>
>>>>><br>
>>>>> Brad<br>
>>>>><br>
>>>>> On Mar 6, 2014, at 12:17 PM, Laurent Chauvin <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>><br>
>>>>> wrote:<br>
>>>>><br>
>>>>> Thank you Bradley.<br>
>>>>><br>
>>>>> Indeed I saw this article, but as it is from 2010, I thought maybe now<br>
>>>>> it would have been integrated into ITK.<br>
>>>>> I will look into that.<br>
>>>>><br>
>>>>> Thank you.<br>
>>>>> -Laurent<br>
>>>>><br>
>>>>><br>
>>>>> On Thu, Mar 6, 2014 at 11:59 AM, Bradley Lowekamp<br>
>>>>> <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>> wrote:<br>
>>>>>><br>
>>>>>> Have a look at this insight journal article:<br>
>>>>>><br>
>>>>>> <a href="http://www.insight-journal.org/browse/publication/721" target="_blank">http://www.insight-journal.org/browse/publication/721</a><br>
>>>>>><br>
>>>>>> I would also find this quite useful, and have been thinking about<br>
>>>>>> adding it to ITK.<br>
>>>>>> Brad<br>
>>>>>> On Mar 6, 2014, at 11:55 AM, Laurent Chauvin<br>
>>>>>> <<a href="mailto:lchauvin@bwh.harvard.edu">lchauvin@bwh.harvard.edu</a>> wrote:<br>
>>>>>><br>
>>>>>> Hello,<br>
>>>>>><br>
>>>>>> I'm trying to develop a filter, but in order to test it, I need to add<br>
>>>>>> some gaussian noise to my image.<br>
>>>>>> I looked for it but I couldn't find a ITK filter to generate noise.<br>
>>>>>><br>
>>>>>> Is there a way to do this ?<br>
>>>>>><br>
>>>>>> Thank you very much.<br>
>>>>>> -Laurent<br>
>>>>>><br>
>>>>>> --<br>
>>>>>> Laurent Chauvin, MS<br>
>>>>>> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
>>>>>> Brigham And Women's Hospital, Harvard Medical School<br>
>>>>>> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
>>>>>> _____________________________________<br>
>>>>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>>>>><br>
>>>>>> Visit other Kitware open-source projects at<br>
>>>>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>>>>><br>
>>>>>> Kitware offers ITK Training Courses, for more information visit:<br>
>>>>>> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
>>>>>><br>
>>>>>> Please keep messages on-topic and check the ITK FAQ at:<br>
>>>>>> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>>>>>><br>
>>>>>> Follow this link to subscribe/unsubscribe:<br>
>>>>>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> The information in this e-mail is intended only for the person to whom<br>
>>>>>> it is<br>
>>>>>> addressed. If you believe this e-mail was sent to you in error and the<br>
>>>>>> e-mail<br>
>>>>>> contains patient information, please contact the Partners Compliance<br>
>>>>>> HelpLine at<br>
>>>>>> <a href="http://www.partners.org/complianceline" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you<br>
>>>>>> in error<br>
>>>>>> but does not contain patient information, please contact the sender<br>
>>>>>> and properly<br>
>>>>>> dispose of the e-mail.<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> --<br>
>>>>> Laurent Chauvin, MS<br>
>>>>> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
>>>>> Brigham And Women's Hospital, Harvard Medical School<br>
>>>>> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
>>>>><br>
>>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Laurent Chauvin, MS<br>
>>>> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
>>>> Brigham And Women's Hospital, Harvard Medical School<br>
>>>> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Laurent Chauvin, MS<br>
>>> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
>>> Brigham And Women's Hospital, Harvard Medical School<br>
>>> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Laurent Chauvin, MS<br>
>> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
>> Brigham And Women's Hospital, Harvard Medical School<br>
>> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Laurent Chauvin, MS<br>
> Surgical Navigation and Robotics Laboratory, Radiology Department<br>
> Brigham And Women's Hospital, Harvard Medical School<br>
> <a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a><br>
><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Laurent Chauvin, MS</div><div>Surgical Navigation and Robotics Laboratory, Radiology Department</div><div>Brigham And Women's Hospital, Harvard Medical School<br>
</div><div><a href="http://wiki.ncigt.org/index.php/User:Lchauvin" target="_blank">http://wiki.ncigt.org/index.php/User:Lchauvin</a></div></div>
</div>