[Insight-users] Noise simulation

Oleksandr Dzyubak adzyubak at gmail.com
Tue Mar 30 11:40:51 EDT 2010


Hi Gaëtan,

I have done my homework.

1) I studied the ITK header.

InsightToolkit/Common/itkMersenneTwisterRandomVariateGenerator.h

In that header the link to the inventors' web page
www.math.keio.ac.jp/~matumoto/emt.html is dead.
The correct and still alive one is below.

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

2) I have also read the article by the inventors
M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally 
equidistributed uniform pseudorandom number generator", ACM Trans. on 
Modeling and Computer Simulation Vol. 8, No. 1, January pp.3-30 (1998).

This classical article (along with others) can be downloaded from
the Makoto Matsumoto's home page.

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/earticles.html

3) From that article:  "A new algorithm called Mersenne Twister
is  proposed for generating uniform pseudorandom numbers."
Period is (2^ 19937) - 1, 632-dimensional equidistribution up to 32-bit 
accuracy.
So the period is a such huge number
that this generator could be considered as a "true random".

4) New debugged and updated release  2009/11/17 of the generator
can be downloaded using link below.

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html


5) I downloaded and tested the updated code version from the link you 
provided.
http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/

a) Compiles -- fine.
b) Works -- fantastic.
c) Tested images are identical to those provided in the submission.

6) Could you upload the revised version to the Insight Journal?
I would be more than happy to write a review and
recommend to add it to the ITK library.


Thanks for nice work,

Alex


Gaëtan Lehmann wrote:
>
> Le 29 mars 10 à 15:54, Oleksandr Dzyubak a écrit :
>
>>
>> Hi Gaëtan,
>>
>
> Hi Alex,
>
>> Whenever I try to send images using a regular email client,
>> my emails get bounced. So I used the web page uploader
>> from nabble.com to send the images. I hope you also got a copy.
>> If not, below is the link to the images.
>>
>> http://old.nabble.com/Noise-simulation-to27990624.html#a28069421
>
> I'd say there is a small difference between the two images, but that's 
> a random process :-)
>
>>
>> About median.cxx. In your submission you use it
>> just as a denoiser to demonstrate that it works nice on, in 
>> particular,  images
>> with "salt-and-pepper",  right?
>
> I included it to experiment a bit with PSNR calculator and denoising. 
> That's really a not much useful program - I didn't event mentioned it 
> in the paper!
>
>>
>> About the generator. How good is it? Is it random or chaotic?
>> What is the cycle?
>
> I can't say at all. I simply modified the Mersenne Twister generator 
> from ITK to make it thread safe.
> I actually don't have much skills in random generator.
>
>>
>> You say that the Gauss has been fixed.
>> Is it possible the get the updated version?
>>
>
> Sure! It is in the main development repository.
>
>   http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/
>
> I think I didn't say that you can use darcs to get it 
> (http://www.darcs.net)
>
>   darcs get http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/
>
> Thanks,
>
> Gaëtan
>
>
>> Thanks,
>>
>> Alex
>>
>> Gaëtan Lehmann wrote:
>>>
>>> Le 26 mars 10 à 16:27, Oleksandr Dzyubak a écrit :
>>>
>>>> Hi Gaëtan,
>>>>
>>>> I downloaded the updated version from your repository that you 
>>>> provided.
>>>> http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/
>>>>
>>>> Below is the result of my tests.
>>>>
>>>> 1)
>>>> The compilation was perfect.
>>>
>>> great :-)
>>>
>>>>
>>>> 2)
>>>> dzyubak at helium: /Original_Images$ ./median cthead1.tif 
>>>> cthead1_median.png | grep " Number Of Threads"
>>>>
>>>> After Running the median program, I do see any difference
>>>> between original and processed images.
>>>> As I can see, in the median.cxx  you just removed the neighborhood 
>>>> radius.
>>>> What is the purpose of being that utility in the submission?
>>>> Can't be the median.cxx  just removed from the package?
>>>>
>>>
>>> It does something here - by default, the radius is 1.
>>> Just try on the output of the salt and pepper filter :-)
>>>
>>>  ./sp ../images/cthead1.tif sp.png
>>>  ./median sp.png out.png
>>>
>>> it is very efficient for this kind of noise.
>>>
>>>> 3)
>>>> dzyubak at helium: /Original_Images$ ./gauss cthead1.tif 
>>>> cthead1_gauss_s22_8_m0.png 22.8 0.0  | grep " Number Of Threads"
>>>> Number Of Threads: 16
>>>>  Global Maximum Number Of Threads: 128
>>>>  Global Default Number Of Threads: 16
>>>>
>>>> The image has the same seeding problem as in the previous version.
>>>> No changes at all.
>>>>
>>>
>>> err, yes, my fault. I forgot that this filter was not using the 
>>> mersenne twister generator.
>>> It's fixed now, by using the same random generator as in the other 
>>> filters :-)
>>>
>>>> 4)
>>>> dzyubak at helium: /Original_Images$ ./sp cthead1.tif 
>>>> cthead1_sp_001.png 0.01 | grep " Number Of Threads"
>>>>
>>>> Number Of Threads: 16
>>>>  Global Maximum Number Of Threads: 128
>>>>  Global Default Number Of Threads: 16
>>>>
>>>> Surprisingly, now cthead1_sp_001.png looks similar to that
>>>> from your submission.  The incorrect seeding problem is gone.
>>>> Noise really looks random.  However, I noticed that your image is  
>>>> "noisier".
>>>> Did you use the same parameter "0.01" or that is still the seeding 
>>>> problem?
>>>
>>> noiser? can your provide the images?
>>>
>>>>
>>>> 5)
>>>> The shot and spekle noise generators work fine and my images
>>>> are identical to yours.
>>>
>>> great :-)
>>>
>>>>
>>>> 6)
>>>> Peak signal to noise ratio. In your submission you have 20 dB. Mine 
>>>> is below.
>>>>
>>>> dzyubak at helium: /Original_Images$ ./psnr cthead1.tif 
>>>> cthead1_median.png
>>>> PSNR: 37.3425 dB
>>>>
>>>> dzyubak at helium: /Original_Images$ ./psnr cthead1.tif 
>>>> cthead1_gauss_s22_8_m0.png
>>>> PSNR: 20.0251 dB
>>>>
>>>> dzyubak at helium: /Original_Images$ ./psnr cthead1.tif 
>>>> cthead1_shot_s015.png
>>>> PSNR: 20.0429 dB
>>>>
>>>> dzyubak at helium: /Original_Images$ ./psnr cthead1.tif 
>>>> cthead1_spekle_s024.png
>>>> PSNR: 20.0901 dB
>>>>
>>>> dzyubak at helium: /Original_Images$ ./psnr cthead1.tif 
>>>> cthead1_sp_001.png
>>>> PSNR: 22.4873 dB
>>>>
>>>> Interesting, the utility says that my salt and pepper is noisier,
>>>> but just visual test yours is as twice noisier. Subjective  judgment?
>>>
>>> PSNR is only a (not so bad) approximation of the image degradation 
>>> as perceived by a human.
>>> Our brain very capable to ignore the noise, and for some case like 
>>> the salt and pepper case, the PSNR is not very representative of our 
>>> feeling.
>>>
>>>>
>>>> Summing up.
>>>> 1) What is the need for median.cxx ?
>>>> Can't be this utility just removed from the submission?
>>>>
>>>> 2) The seeding problem in the Gauss noise generator is still there.
>>>>
>>>> Regards,
>>>>
>>>> Alex
>>>>
>>>>
>>>> Gaëtan Lehmann wrote:
>>>>>
>>>>> Le 25 mars 10 à 23:27, Gaëtan Lehmann a écrit :
>>>>>
>>>>>>
>>>>>> Hi Alex,
>>>>>>
>>>>>> I think there is a problem with multithreading and the random 
>>>>>> generator - more specifically, the seeds are the same in all the 
>>>>>> threads.
>>>>>> I didn't noticed this on my macbook with only 2 cores, even when 
>>>>>> increasing the number of threads to a higher number than the 
>>>>>> number of cores, but I see the same behavior on my workstation 
>>>>>> with 16 threads.
>>>>>>
>>>>>> How many threads are running in parallel on your system? The 
>>>>>> number is displayed while running one of the noise generator
>>>>>>
>>>>>> [glehmann at gbook build]$ ./shot ../images/cthead1.tif toto.png | 
>>>>>> grep "  Number Of Threads:"
>>>>>>  Number Of Threads: 2
>>>>>>  Number Of Threads: 2
>>>>>>
>>>>>> You can limit the number of threads to a small number, or even to 
>>>>>> 1, with
>>>>>>
>>>>>> export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
>>>>>>
>>>>>> to workaround the problem.
>>>>>>
>>>>>> I will restore the (non thread safe) seeding behavior in 
>>>>>> ThreadSafeMersenneTwisterRandomVariateGenerator and make it 
>>>>>> thread safe with a lock so that 2 threads can't get the same seed.
>>>>>>
>>>>>
>>>>> This is fixed in the main repository:
>>>>>
>>>>> http://mima2.jouy.inra.fr/darcs/contrib-itk/noise/
>>>>>
>>>>> As well as the problem you have reported in median.cxx.
>>>>> Please let me know if there is something else wrong!
>>>>>
>>>>> Gaëtan
>>>>>
>>>>>
>>>>>> Thanks for the report!
>>>>>>
>>>>>> Gaëtan
>>>>>>
>>>>>>
>>>>>> Le 25 mars 10 à 22:47, Oleksandr Dzyubak a écrit :
>>>>>>
>>>>>>> Dear ITK users,
>>>>>>>
>>>>>>> Did anybody tested the noise simulation codes from the submission
>>>>>>> "Noise simulation" http://hdl.handle.net/10380/3158 ?
>>>>>>> The most needed (for me at least) noise generators
>>>>>>> (Gauss and salt and pepper)
>>>>>>> produce corrupted images with periodic line patterns
>>>>>>> (see attached images). To generate those images, I followed
>>>>>>> the parameter recommendations taken from the submission.
>>>>>>>
>>>>>>> ./gauss cthead1.tif cthead1_gauss_s22_8_m0.png 22.8 0
>>>>>>> ./sp cthead1.tif cthead1_sp_0016.png 0.016
>>>>>>>
>>>>>>> Did anybody get similar results?
>>>>>>>
>>>>>>> Alex
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Oleksandr Dzyubak wrote:
>>>>>>>> Hi Gaëtan,
>>>>>>>>
>>>>>>>> Nice and long awaited work.
>>>>>>>> I found a tiny typo in your code that prevents the submitted 
>>>>>>>> codes from
>>>>>>>> being compiled.
>>>>>>>> At least on my Linux box. The typo is sitting in your 
>>>>>>>> median.cxx and the
>>>>>>>> fix is below.
>>>>>>>>
>>>>>>>> // Part that gives the errors.
>>>>>>>> /*
>>>>>>>> FilterType::RadiusType r;
>>>>>>>> r.Fill(2);
>>>>>>>> //  filter->SetRadius(r);
>>>>>>>> */
>>>>>>>>
>>>>>>>> //  this fix solves the problem.
>>>>>>>> IType::SizeType r;
>>>>>>>> r[0] = 1;
>>>>>>>> r[1] = 1;
>>>>>>>> filter->SetRadius(r);
>>>>>>>>
>>>>>>>> Could you please add the fix and upload the code?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Alex
>>>>>>>>
>>>>>>>
>>>>>>> <cthead1_gauss_s22_8_m0.png><cthead1_sp_0016.png>
>>>>>>
>>>>>> -- 
>>>>>> Gaëtan Lehmann
>>>>>> Biologie du Développement et de la Reproduction
>>>>>> INRA de Jouy-en-Josas (France)
>>>>>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>>>>>> http://voxel.jouy.inra.fr  http://www.itk.org
>>>>>> http://www.mandriva.org  http://www.bepo.fr
>>>>>>
>>>>>> _____________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Kitware offers ITK Training Courses, for more information visit:
>>>>>> http://www.kitware.com/products/protraining.html
>>>>>>
>>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>
>>>>
>>>
>>
>



More information about the Insight-users mailing list