向图像添加泊松噪声 [英] Adding poisson noise to an image

查看:469
本文介绍了向图像添加泊松噪声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些图像需要添加更多的泊松噪声,以便对其进行更彻底的分析.我知道您可以在MATLAB中执行此操作,但是如何在Python中执行此操作呢?到目前为止,搜索没有任何结果.

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 about doing it in Python? Searches have yielded nothing so far.

推荐答案

如果您可以使用numpy/scipy,则以下内容应会有所帮助.我建议您将数组转换为浮点数以进行中间计算,然后将其转换回uint8以进行输出/显示.由于泊松噪声都> = 0,因此您需要决定在转换回uint8时如何处理数组溢出.您可以根据自己的目标进行缩放或截断.

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...

这篇关于向图像添加泊松噪声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆