2014-04-09 5 views
0

로우 패스 필터를 적용한 후 이미지에 화이트 노이즈를 추가하려고합니다. 내가 matlab에 그것을하는 방법을 알고 있지만 파이썬에서 작동하도록 전화를 해야할지 모르겠다.파이썬에서 imnoise?

import matplotlib.pyplot as plt 
import numpy as np 
import scipy.misc 
from scipy import ndimage 
import Image 

J = imnoise(im,'salt & pepper',0.02); 
figure.imshow(J) 

가져올 다른 항목은 무엇입니까? 아니면 소음을 추가하는 다른 방법이 있습니까?

+0

나는 오류를 얻을 : 나가서 설명하자면 NameError : AttributeError : '모듈'개체가 어떤 속성 'imnoise을'이없는 이름 'imnoise'나는 오류가 나는 np.imnoise을하려고하면 (단지 확인) 정의되지 않은 – user3433572

답변

2

노이즈 제거에 대한 설명에서이 튜토리얼은 이미지에 백색 잡음을 추가합니다. noisy = l + 0.4 * l.std() * np.random.random(l.shape) 여기서 l은 이미지입니다.

http://scipy-lectures.github.io/advanced/image_processing/#denoising

일반적으로, 당신은 당신이 원본 사진을 사용하고자하는 소음으로 가득 매트릭스를 추가하여 간단하게 노이즈를 추가 할 수 있어야합니다.

1

scikit-image은 MATLAB에서 imnoise과 유사한 기능 random_noise을 제공합니다.

skimage.util.random_noise(image, mode='gaussian', seed=None, clip=True, **kwargs) 

그것은 다음과 같은 모드를 지원합니다 : MATLAB에서 imnoise에서 한 가지 차이점이 함수의 출력은 항상 부동 소수점 이미지가 될 것입니다

‘gaussian’ Gaussian-distributed additive noise.

‘localvar’ Gaussian-distributed additive noise, with specified local variance at each point of image

‘poisson’ Poisson-distributed noise generated from the data.

‘salt’ Replaces random pixels with 1.

‘pepper’ Replaces random pixels with 0.

‘s&p’ Replaces random pixels with 0 or 1.

‘speckle’ Multiplicative noise using out = image + n*image, where n is uniform noise with specified mean & variance.

.

입력 이미지가 예를 들어 uint8 그레이 스케일 이미지 인 경우 처음에는 float로 변환되지만 출력 이미지는 입력 이미지와 동일한 클래스로 변환되지 않습니다.

따라서 이미지 클래스를 신경 쓰는 경우 출력을 직접 변환해야합니다 (예 : skimage.img_as_ubyte).