BaseImageRestore.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:NGImageProcessor 作者: artzers 项目源码 文件源码
def WienerFilterDemo(self, img):
        img = np.int16(img)
        noise = self.noiseGenerator.GuassNoise(img, 0, 10, np.int32(img.size))
        nImg = img + noise
        fn = np.fft.fftshift(np.fft.fft2(noise))
        Sn = np.abs(fn) ** 2.0
        ffImg = np.fft.fftshift(np.fft.fft2(img))
        Sf = np.abs(ffImg) ** 2.0
        H = self.GenerateHDemo(img.shape)
        fImg = np.fft.fftshift(np.fft.fft2(img))
        gImg = np.fft.ifft2(np.fft.ifftshift(fImg * H))
        gImg += noise
        fgImg = np.fft.fftshift(np.fft.fft2(gImg))
        wH = (H * (np.abs(H) ** 2.0 + Sn / Sf)) / np.abs(H) ** 2.0
        H1 = self.IdeaLowHInverse(wH, 500)
        ggImg = np.fft.ifft2(np.fft.ifftshift(fgImg * H1))
        cv2.namedWindow("orig")
        cv2.imshow("orig", np.uint8(img))
        cv2.namedWindow("g")
        cv2.imshow("g", np.uint8(gImg))
        cv2.namedWindow("Wiener filter restore")
        cv2.imshow("Wiener filter restore", np.uint8(ggImg))
        cv2.waitKey(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号