用Python中的pyFITS计算图像的平均值

2024-09-27 19:24:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试对随机文本做一个QR,用ImageFilter模糊它,然后找到未存储图像的平均值,并从失真图像的平均值中去掉这个值。在

我找到了pyFITS,但我不明白如何收集图像数据,下面是我的代码:

def show_image1(filename):
     IM=Image.open(filename)
     IM.show()

    QR = "HIDUGHEDG[REJG[ERWJGFERWJ[GJREJGE[RJ[]]]]]"


if __name__ == "__main__":
    myqr = qrcode.make(QR)
    #myqr.show()
    myqr.save("myqr4.png") 



file1 = 'myqr4.png'

ima = pyfits.getdata('myqr4.jpg')

#blurred  = ndimage.gaussian_filter(file1, sigma=3)



im = Image.open('myqr4.png')
im2 = im.convert('RGBA')
im3 = im2.filter(ImageFilter.BLUR)
scipy.misc.imsave('blurred.jpg', im3)
im_blur = Image.open('blurred.jpg')
im_blur.show()

im = pyfits.getdata('blurred.jpg')

print ima - im

理想情况下,我想模糊图像使用

^{pr2}$

但它显示'undefined name'ndimage',即使我用import导入了它scipy.n图像在

但无论如何我想

sigma = x

然后在1和5之间循环x(sigma)的值,然后显示每个失真图像的平均值,这可能吗?在

谢谢你在这方面的任何帮助。在


Tags: 图像imagepngshowopenfilenamesigma平均值
1条回答
网友
1楼 · 发布于 2024-09-27 19:24:46

只需计算图像平均值的平均值,就可以将scipy库与python一起使用。 样品代码:-在

from scipy import misc
image_name = 'Birds.jpg'
calc_mean = misc.imread(image_name)
print calc_mean.mean()

相关问题 更多 >

    热门问题