UOMOP
Add AWGN to image 본문
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude_fshift = np.log(np.abs(fshift) + 1)
ishift = np.fft.ifftshift(fshift)
img = np.abs(np.fft.ifft2(ishift))
plt.subplot(121),plt.imshow(img, cmap = 'gray')
plt.title('T-domain'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(magnitude_fshift, cmap = 'gray')
plt.title('F-domain'), plt.xticks([]), plt.yticks([])
plt.show()
import acoustics
def add_AWGN_to_img(img, SNRdB) :
height, width = img.shape
noise = acoustics.generator.white(img.size).reshape(img.shape)
SNR = 10.0**(SNRdB/10.0)
current_SNR = np.mean(img) / np.std(noise)
noise *= (current_SNR / SNR)
return img + noise
img_SNR_1 = add_AWGN_to_img(img, 1)
plt.imshow(img_SNR_1, cmap = 'gray')
img_SNR_10 = add_AWGN_to_img(img, 10)
plt.imshow(img_SNR_10, cmap = 'gray')
img_SNR_100 = add_AWGN_to_img(img, 100)
plt.imshow(img_SNR_100, cmap = 'gray')
'Wireless Comm. > Python' 카테고리의 다른 글
Is the high frequency component more robust to noise? (PSNR Ver.) (0) | 2023.05.24 |
---|---|
High freq. vs Low freq. vs Original (0) | 2023.05.24 |
plt.imshow 파란색으로 되는 현상 (0) | 2023.05.24 |
AutoEncoder for Fashion MNIST (0) | 2023.05.11 |
Image PSNR Check_20230508 (0) | 2023.05.08 |
Comments