Anda di halaman 1dari 43

ANALISIS DAN PENGOLAHAN CITRA

TUGAS
REDUKSI NOISE PADA GAMBAR CITRA DENGAN
MENGUNAKAN FILTER

DOSEN :
DR BUDI SETIYONO, S.SI, MT
19720207 199702 1 001

OLEH:
GITHA ANDANI SUHARNINGTYAS
06111950010008

DEPARTEMEN MATEMATIKA
FAKULTAS SAINS DAN DATA ANALITIK
INSTITUT TEKNOLOGI SEPULUH NOPEMBER
2020
A. Simulasi GUI
1. Load Gambar Asli

2. Gambar Asli dengan Noise


NOISE SIMULASI

Gaussian
(Gambar 1)
Speckle
(Gambar 2)

Salt & Pepper


(Gambar 3)
Berdasarkan hasil simulasi perilaku model noise Gaussian, Speckle, dan Salt & Pepper terhadap
gambar citra asli dapat disimpulkan bahwa
a. Noise Gaussian
Pada Gambar 1 diberi perlakuan yang berbeda dengan mengubah parameter mean dan
varian dari model Gausian. Hal ini dapat dibandingkan dimana saat diberikan mean 0.6 dan
varians 0.07 dengan mean 0.6 dan varians 0.03, artinya mean yang diberkan tidak berubah tetapi
untuk varians diperkecil terlihat bahwa pada gambar tampak terdapat noise lebih banyak untuk
varians yang besar sedangkan untuk mean 0.8 dan varians 0.07 dengan mean 0.4 dan varians 0.04
artinya mean berubah tetapi varians tetap gambar dengan noise tampak lebih cerah dibandingkan
dengan mean kecil
b. Noise Speckle
Pada Gambar 2 dengan noise speckle diberikan perlakuan varians yang berbeda. Sehingga
dapat disimpulkan bahwa semakin kecil varians yang diberikan maka gambar akan tampak lebih
kontras(tajam) pada objek orang seperti gambar asli dibandingkan dengan gambar varians yang
besar.
c. Noise Salt and Pepper
Pada Gambar 3 dengan noise salt and pepper diberikan density yang berbeda pada
gambar. Sehingga dapat menghasilkan gambar dengan noise terlihat banyak ketika density besar.
Hal ini dikarenakan density merupakan suatu peluang gabungan antara peluang noise salt dan
peluang noise pepper. Sehingga jika density kecil maka gambar tampak dengan noise sedikit
dibandingkan density besar
3. Gambar Dengan Noise Gaussian Direduksi dengan Filter
Filter SIMULASI

Mean

Median
Low Pass

High Pass
MSE, RMSE, PSNR
Filter
Gambar 1 Gambar 2 Gambar 3 Gambar 4

Mean

Median

Low
Pass
High
Pass

Berdasarkan hasil simulasi gambar dengan noise Gaussian selanjutnya dilakukan reduksi
noise menggunakan filter mean, median, low pass dan high pass. Hasil filter mean dengan noise
Gaussian terlihat bahwa gambar dengan mean 0.4 dan varians 0.07 artinya semakin kecil nilai
mean dan semakin besar nilai varians akan menghasilkan gambar yang lebih jelas dan mendekati
gambar asli. Dibandingkan filter median dan low pass masih sedikit tampak ada noise pada
gambar, serta filter high pass terlihat jauh dari gambar asli. Tetapi untuk PNSR tertinggi diperoleh
pada gambar 2 dengan filter median
4. Gambar Dengan Noise Speckle Direduksi dengan Filter
Filter SIMULASI

Mean

Median
Low Pass

High Pass
MSE, RMSE, PSNR
Filter
Gambar 1 Gambar 2 Gambar 3 Gambar 4

Mean

Median

Low
Pass
High
Pass

Berdasarkan hasil simulasi gambar dengan noise speckle selanjutnya dilakukan reduksi noise
menggunakan filter mean, median, low pass dan high pass. Hasil filter median dengan noise
speckle gambar terlihat lebih jelas dengan varians 0.2 artinya semakin kecil nilai varians akan
menghasilkan gambar yang lebih jelas dan mendekati gambar asli. Dibandingkan filter mean dan
low pass masih sedikit tampak ada noise pada gambar dan kontras rendah, serta filter high pass
terlihat jauh dari gambar asli masih tampak banyak noise. Selanjutnya untuk PNSR terbaik juga
pada gambar 4 deng filter median
5. Gambar Dengan Noise Salt & Pepper Direduksi dengan Filter
Filter SIMULASI

Mean
Median

Low Pass
High Pass
MSE, RMSE, PSNR
Filter
Gambar 1 Gambar 2 Gambar 3 Gambar 4

Mean

Median

Low
Pass
High
Pass

Berdasarkan hasil simulasi gambar dengan noise Salt and Pepper. Hasil filter median dengan
noise Salt and Pepper terlihat bahwa menghasilkan gambar yang lebih jelas dan mendekati gambar
asli. Dibandingkan filter median dan low pass masih sedikit tampak ada noise pada gambar, serta
filter high pass terlihat jauh dari gambar asli. Selanjutnya, nilai PNSR terbesar diperoleh pada
gambar 4 dengan filter median, hal ini menunjukkan penapis yang paling baik

B. Source Code
Load Gambar
function pushbutton1_Callback(hObject, eventdata, handles)
filename = get(handles.filename,'string');
if isempty(filename)
msgbox('Pilih File!!', 'informasi','warn');
else
jenis3 = filename(1,length(filename)-3:end);
jenis4 = filename(1,length(filename)-4:end);
if jenis3=='.jpg'
axes(handles.axes1)
gambar=imread(filename);
imshow(gambar);
elseif jenis3=='.png'
axes(handles.axes1)
gambar=imread(filename);
imshow(gambar);
end
end

bar = waitbar(1, 'Loading...........');


for i=1:100;
waitbar(i/100,bar,'Loading......');
pause(0.01);
end
close(bar);
function pushbutton12_Callback(hObject, eventdata, handles)
[filename, pathname]=uigetfile({'*.jpg;*.png;*.xlsx;*.dat;*.csv'});
if isequal(filename,0)
set(handles.filename,'string','');

else
gabung=[pathname filename];
set(handles.filename,'string',gabung);

end

Gambar dengan Noise Gaussian, Speckle, Salt & Pepper


function Gaussian_Callback(hObject, eventdata, handles)
set(handles.Gaussian,'value',0,'BackgroundColor', 'white');
p = 1;
handles.p = p;
disp(p)
guidata(hObject,handles);

function Speckle_Callback(hObject, eventdata, handles)


set(handles.Speckle,'value',0,'BackgroundColor', 'white');
p = 2;
handles.p = p;
disp(p)
guidata(hObject,handles);

function salt_Callback(hObject, eventdata, handles)


set(handles.salt,'value',0,'BackgroundColor', 'white');
p = 3;
handles.p = p;
disp(p)
guidata(hObject,handles);

function proses_Callback(hObject, eventdata, handles)


ambil = handles.p;
switch ambil
case 1
filename = get(handles.filename,'string');

axes(handles.axes2)
gambar = imread(filename);
gaussian1 = imnoise(gambar,'gaussian',0.6, 0.07);
imshow(gaussian1);
title('Mean 0.6, Varians 0.07', 'BackgroundColor','white')
handles.gaussian1 = gaussian1;
guidata(hObject,handles);

axes(handles.axes29)
gambar = imread(filename);
gaussian2 = imnoise(gambar,'gaussian',0.6, 0.03);
imshow(gaussian2);
title('Mean 0.6, Varians 0.03', 'BackgroundColor','white')
handles.gaussian2 = gaussian2;
guidata(hObject,handles);

axes(handles.axes31)
gambar = imread(filename);
gaussian3 = imnoise(gambar,'gaussian',0.8, 0.07);
imshow(gaussian3);
title('Mean 0.8, Varians 0.07', 'BackgroundColor','white')
handles.gaussian3 = gaussian3;
guidata(hObject,handles);

axes(handles.axes30)
gambar = imread(filename);
gaussian4 = imnoise(gambar,'gaussian',0.4, 0.07);
imshow(gaussian4);
title('Mean 0.4, Varians 0.07', 'BackgroundColor','white')
handles.gaussian4 = gaussian4;
guidata(hObject,handles);

case 2
filename = get(handles.filename,'string');

axes(handles.axes2)
gambar = imread(filename);
speckle1 = imnoise(gambar,'speckle',0.8);
imshow(speckle1);
title('Varians 0.8', 'BackgroundColor','white')
handles.speckle1 = speckle1;
guidata(hObject,handles);

axes(handles.axes29)
gambar = imread(filename);
speckle2 = imnoise(gambar,'speckle',0.6);
imshow(speckle2);
title('Varians 0.6', 'BackgroundColor','white')
handles.speckle2 = speckle2;
guidata(hObject,handles);

axes(handles.axes31)
gambar = imread(filename);
speckle3= imnoise(gambar,'speckle',0.4);
imshow(speckle3);
title('Varians 0.07', 'BackgroundColor','white')
handles.speckle3 = speckle3;
guidata(hObject,handles);

axes(handles.axes30)
gambar = imread(filename);
speckle4 = imnoise(gambar,'speckle',0.2);
imshow(speckle4);
title('Varians 0.2', 'BackgroundColor','white')
handles.speckle4 = speckle4;
guidata(hObject,handles);
case 3
filename = get(handles.filename,'string');

axes(handles.axes2)
gambar = imread(filename);
salt1 = imnoise(gambar,'salt & pepper',0.8);
imshow(salt1);
title('Density 0.8', 'BackgroundColor','white')
handles.salt1 = salt1;
guidata(hObject,handles);

axes(handles.axes29)
gambar = imread(filename);
salt2 = imnoise(gambar,'salt & pepper',0.6);
imshow(salt2);
title('Density 0.6', 'BackgroundColor','white')
handles.salt2 = salt2;
guidata(hObject,handles);

axes(handles.axes31)
gambar = imread(filename);
salt3= imnoise(gambar,'salt & pepper',0.4);
imshow(salt3);
title('Density 0.07', 'BackgroundColor','white')
handles.salt3 = salt3;
guidata(hObject,handles);

axes(handles.axes30)
gambar = imread(filename);
salt4 = imnoise(gambar,'salt & pepper',0.2);
imshow(salt4);
title('Density 0.2', 'BackgroundColor','white')
handles.salt4 = salt4;
guidata(hObject,handles);

end

handles.ambil= ambil;
disp(ambil)
guidata(hObject,handles);

Reduksi Noise dengan Filter


Filter Mean
function Mean_Callback(hObject, eventdata, handles)
ambil = handles.p;
filename = get(handles.filename,'string');
gambarasli = imread(filename);
[row,col,~]=size(gambarasli);
switch ambil
case 1
disp('Reduksi Noise Gaussian Dengan Mean Filter')
gambar = handles.gaussian1;
axes(handles.axes3)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 1','BackgroundColor','white')

MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian2;
axes(handles.axes33)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian3;
axes(handles.axes34)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian4;
axes(handles.axes35)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 2
disp('Reduksi Noise Speckle Dengan Mean Filter')
gambar = handles.speckle1;
axes(handles.axes3)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle2;
axes(handles.axes33)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle3;
axes(handles.axes34)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle4;
axes(handles.axes35)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 3
disp('Reduksi Noise Salt and Pepper Dengan Mean Filter')
gambar = handles.salt1;
axes(handles.axes3)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt2;
axes(handles.axes33)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt3;
axes(handles.axes34)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt4;
axes(handles.axes35)
mean = imfilter(gambar,ones(5)/25);
imshow(mean);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-mean).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

end

Filter Median
function Median_Callback(hObject, eventdata, handles)
ambil = handles.p;
filename = get(handles.filename,'string');
gambarasli = imread(filename);
[row,col,~]=size(gambarasli);
switch ambil
case 1
disp('Reduksi Noise Gaussian Dengan Median Filter')
gambar = handles.gaussian1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes3)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

size(gambar)
axes(handles.axes33)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

size(gambar)
axes(handles.axes34)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

size(gambar)
axes(handles.axes35)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 2
disp('Reduksi Noise Speckle Dengan Median Filter')
gambar = handles.speckle1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes3)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes33)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes34)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes35)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 3
disp('Reduksi Noise Salt & Pepper Dengan Median Filter')
gambar = handles.salt1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes3)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes33)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes34)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);

axes(handles.axes35)
median(:,:,1) = medfilt2(red);
median(:,:,2) = medfilt2(green);
median(:,:,3) = medfilt2(blue);
imshow(median);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-median).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

end

Filter Low Pass


function Lowpass_Callback(hObject, eventdata, handles)
ambil = handles.p;
filename = get(handles.filename,'string');
gambarasli = imread(filename);
[row,col,~]=size(gambarasli);
switch ambil
case 1
disp('Reduksi Noise Gaussian Dengan Low Pass Filter')
gambar = handles.gaussian1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes3)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes33)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes34)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes35)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 2
disp('Reduksi Noise Speckle Dengan Low Pass Filter')
gambar = handles.speckle1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes3)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes33)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes34)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)
gambar = handles.speckle4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes35)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 3
disp('Reduksi Noise Salt & Pepper Dengan Low Pass Filter')
gambar = handles.salt1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes3)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)
gambar = handles.salt2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes33)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes34)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
lpf =[1 1 1;1 1 1;1 1 1]/9;

axes(handles.axes35)
low(:,:,1)=uint8(conv2(double(red), lpf,'same'));
low(:,:,2)=uint8(conv2(double(green), lpf,'same'));
low(:,:,3)=uint8(conv2(double(blue), lpf,'same'));
imshow(low);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-low).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)
end

Filter High Pass


function Highpass_Callback(hObject, eventdata, handles)
ambil = handles.p;
filename = get(handles.filename,'string');
gambarasli = imread(filename);
[row,col,~]=size(gambarasli);
switch ambil
case 1
disp('Reduksi Noise Gaussian Dengan High Pass Filter')
gambar = handles.gaussian1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes3)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes33)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes34)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.gaussian4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes35)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 2
disp('Reduksi Noise Speckle Dengan High Pass Filter')
gambar = handles.speckle1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes3)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes33)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes34)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.speckle4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes35)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

case 3
disp('Reduksi Noise Salt & Pepper Dengan High Pass Filter')
gambar = handles.salt1;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes3)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 1','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 1 RGB')
disp('-----------------------------')
disp('MSE Gambar 1 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 1 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 1 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt2;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes33)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 2','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 2 RGB')
disp('-----------------------------')
disp('MSE Gambar 2 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 2 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 2 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt3;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes34)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 3','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 3 RGB')
disp('-----------------------------')
disp('MSE Gambar 3 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 3 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 3 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)

gambar = handles.salt4;
red = gambar(:,:,1);
green = gambar(:,:,2);
blue = gambar(:,:,3);
hpf =[-1 -1 -1;-1 8 -1;-1 -1 -1];

axes(handles.axes35)
high(:,:,1)=uint8(conv2(double(red), hpf,'same'));
high(:,:,2)=uint8(conv2(double(green), hpf,'same'));
high(:,:,3)=uint8(conv2(double(blue), hpf,'same'));
imshow(high);
title('Hasil Gambar 4','BackgroundColor','white')
MSE = sum(sum((gambarasli-high).^2))/(row*col);
RMSE = sqrt(MSE);
PNSR = 10*log10(256*256/MSE);
disp('MSE, RMSE dan PNSR Gambar 4 RGB')
disp('-----------------------------')
disp('MSE Gambar 4 RGB')
disp('*****************')
fprintf('MSE %d \n', MSE)
disp('RMSE Gambar 4 RGB')
disp('*****************')
fprintf('RMSE %d \n', RMSE)
disp('PNSR Gambar 4 RGB')
disp('*****************')
fprintf('PNSR %d \n', PNSR)
end

Anda mungkin juga menyukai