Adding poisson noise to an image

后端 未结 5 621
忘了有多久
忘了有多久 2021-01-06 09:55

I have some images that I need to add incremental amounts of Poisson noise to in order to more thoroughly analyze them. I know you can do this in MATLAB, but how do you go a

5条回答
  •  离开以前
    2021-01-06 10:39

    If numpy/scipy are available to you, then the following should help. I recommend that you cast the arrays to float for intermediate computations then cast back to uint8 for output/display purposes. As poisson noise is all >=0, you will need to decide how you want to handle overflow of your arrays as you cast back to uint8. You could scale or truncate depending on what your goals were.

    filename = 'myimage.png'
    imagea = (scipy.misc.imread(filename)).astype(float)
    
    poissonNoise = numpy.random.poisson(imagea).astype(float)
    
    noisyImage = imagea + poissonNoise
    
    #here care must be taken to re cast the result to uint8 if needed or scale to 0-1 etc...
    

提交回复
热议问题