Sunday, September 3, 2017

DENOISING ADAPTIF BERBASIS FFT
















Berikut kode sumber GUI MATLAB:

function uipanel4_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel4
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

global I_derau
global I
g = I_derau;
[N,M]=size(g);

         
%Melakukan transformasi FFT 2D
F=fftshift(fft2(double(g)));
     
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
     
switch get(eventdata.NewValue,'Tag') % Mendapatkan tag dari objek terseleksi
    case 'radiobutton1'
        %Universal Shrink (US)
        M=size(g,1)^2;
        US=(N*N)*variansi*sqrt(2*log(M))

        %Ambang-batas halus
        softC=wthresh(F,'s',US);
     
        %Transformasi FFT 2D Balik
        citraBaru=ifft2(fftshift(softC));

        %Menampilkan hasil ambang-batas pada koefisien FFT 2D
        axes(handles.axes2)
        imshow(100*log(1+abs(softC)),[]); axis off; colormap(gray);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imshow(citraBaru,[]); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));

    case 'radiobutton2'
        %Visu Shrink (VS)
        N=size(g,1)^2;
        VS=(N)*variansi*sqrt(2*log(N*N)) + 0.25*max(max(abs(F)))/(N)

        %Ambang-batas halus
        softC=wthresh(F,'s',VS);
     
        %Transformasi FFT 2D Balik
        citraBaru=ifft2(fftshift(softC));

        %Menampilkan hasil ambang-batas pada koefisien FFT 2D
        axes(handles.axes2);
        imshow(100*log(1+abs(softC)),[]); axis off; colormap(gray);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imshow(citraBaru,[]); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));
     
    case 'radiobutton3'
        %Minimax Shrink (MS)
        N=size(g,1)^2;
        MS=(0.0025*N)*(0.394+0.264*log(N)+ 0.5*max(max(abs(F)))/(N))

        %Ambang-batas halus
        softC=wthresh(F,'s',MS);
     
        %Transformasi FFT 2D Balik
        citraBaru=ifft2(fftshift(softC));

        %Menampilkan hasil ambang-batas pada koefisien FFT 2D
        axes(handles.axes2)
        imshow(100*log(1+abs(softC)),[]); axis off; colormap(gray);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imshow(citraBaru,[]); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));
     
     
    case 'radiobutton4'
        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));


        % Ambang-batas SURE Shrink (SS)
        SS=(0.0015*N)*(0.394+0.264*log(N)+ 0.5*max(max(abs(F)))/(N))

        %Ambang-batas halus
        softC=wthresh(F,'s',SS);
     
        %Transformasi FFT 2D Balik
        citraBaru=ifft2(fftshift(softC));

        %Menampilkan hasil ambang-batas pada koefisien FFT 2D
        axes(handles.axes2)
        imshow(100*log(1+abs(softC)),[]); axis off; colormap(gray);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imshow(citraBaru,[]); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit18, 'String', num2str(MSE1));
     
     
    case 'radiobutton9'
        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Ambang-batas Bayes Shrink (BS)
        BS = bayesthf(g,variansi) + 0.25*max(max(abs(F)))/(N);

        %Ambang-batas halus
        softC=wthresh(F,'s',BS);
     
        %Transformasi FFT 2D Balik
        citraBaru=ifft2(fftshift(softC));

        %Menampilkan hasil ambang-batas pada koefisien FFT 2D
        axes(handles.axes2)
        imshow(100*log(1+abs(softC)),[]); axis off; colormap(gray);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imshow(citraBaru,[]); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit18, 'String', num2str(MSE1));
end




No comments: