資源簡介
該程序給圖像添加正弦噪聲,然后使用類似Notch Filter將該噪聲在Fourier空間中去除。
代碼片段和文件信息
function?[?imageFiltered?]?=?removeSinoise(?strOriginalImage?A?U0?V0)
%%?Function?Description
%REMOVESINOISE?Add?sinusoidal?noise?to?an?image?and?then?remove?the?noise
%???Add?sinusoidal?noise?to?an?image?STRORIGINALIMAGE?and?the?sinusoidal
%???noise?N(xy)?is?determined?by?the?parameter?AUV?in?the?following?
%???formula:?N(xy)?=?Asin(2*pi*U0*x?+?2*pi*V0*y).
%???After?N(xy)?is?added?the?noise?is?removed?in?the?Fourier?Space?and
%???then?get?the?returned?image?IMAGEFILTERED
%
%???STRORIGINALIMAGE
%???????The?original?input?image?to?be?operated.?It?can?be?RGB?image?or?
%???????GRAY?image.
%???A
%???????The?amplitude?of?the?noise?to?add.
%???U0?V0
%???????The?Vertical?and?Horizontal?direction?components?of?the?sinusoidal
%???????noise?respectively.?They?determine?the?frequencies?in?vertical?
%???????and?horizontal?direction.
%
%???Author:?Guangchun?Cheng?Department?of?Computer?Science?and?Egineering
%??????????????@?University?of?North?Texas.
%???Date:???10/15/2010
close?all;
%%?STEP1~STEP?:?Generate?Noisy?Image
%???STEP?1:?read?an?image?and?convert?it?to?gray?scale?if?it‘s?RGB?image.
imageOrigin?=?imread(strOriginalImage);
[M?N?P]?=?size(imageOrigin);
if?P>1
????imageGray?=?rgb2gray(imageOrigin);
end
figure?imshow(mat2gray(imageGray));?title(‘Original?Image‘);
%???show?the?Fourier?frequency?spectrum?of?the?original?image
%?imageGrayDouble?=?double(imageGray);
%?imFft?=?fftshift(fft2(imageGrayDouble));
%?imFft?=?log(1+abs(imFft));
%?figure?imshow(mat2gray(imFft));?title(‘Original?Lenna?Freq?Spectrum‘);
%???STEP?2:?Generate?noise?image?N(xy)=Asin(2*pi*U0*x/M?+?2*pi*V0*y/N)?
%???according?to?the?input?parameters?(A?U0?V0).
imNoise=zeros(MN);
for?x=1:M
????for?y=1:N
????????imNoise(xy)=A(1)*sin(2*pi*(x/M)*U0?+?2*pi*(y/N)*V0);
????end
end
figure?imshow(mat2gray(imNoise));?title(‘Noise?Image‘);
%???show?the?Fourier?frequency?spectrum?image?of?the?noise?image
imFft?=?fft2(imNoise);
imFft?=?log(1+abs(fftshift(imFft)));
figure?imshow(mat2gray(imFft));?title(‘Noise?Freq?Spectrum‘);
%???STEP?3:?Add?noise?image?to?the?original?image?and?show?the?result?
%???in?spatial?space.
imNoiseUint?=?uint8(imNoise);
imNoisyImage?=?mat
- 上一篇:電流滯環整流matlab仿真模型
- 下一篇:PLA簡單matlab實現
評論
共有 條評論