classdef Extra_fourier < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                  matlab.ui.Figure
        SizeSlider                matlab.ui.control.Slider
        SizeSliderLabel           matlab.ui.control.Label
        KernelShapeDropDown       matlab.ui.control.DropDown
        KernelShapeDropDownLabel  matlab.ui.control.Label
        RadiusSpinner             matlab.ui.control.Spinner
        RadiusSpinnerLabel        matlab.ui.control.Label
        SigmaSlider               matlab.ui.control.Slider
        SigmaSliderLabel          matlab.ui.control.Label
        YsizeSpinner              matlab.ui.control.Spinner
        YsizeSpinnerLabel         matlab.ui.control.Label
        XsizeSpinner              matlab.ui.control.Spinner
        XsizeSpinnerLabel         matlab.ui.control.Label
        FilterTypeDropDown        matlab.ui.control.DropDown
        FilterTypeDropDownLabel   matlab.ui.control.Label
        ValueSlider               matlab.ui.control.Slider
        ValueSliderLabel          matlab.ui.control.Label
        YSpinner                  matlab.ui.control.Spinner
        YSpinnerLabel             matlab.ui.control.Label
        XSpinner                  matlab.ui.control.Spinner
        XSpinnerLabel             matlab.ui.control.Label
        ActionButtonGroup         matlab.ui.container.ButtonGroup
        CompressionButton         matlab.ui.control.ToggleButton
        FiltrationButton          matlab.ui.control.ToggleButton
        ChangesinglefouierfunctionButton  matlab.ui.control.ToggleButton
        ResetButton               matlab.ui.control.Button
        LoadButton                matlab.ui.control.Button
        PhiAxes                   matlab.ui.control.UIAxes
        AmpAxes                   matlab.ui.control.UIAxes
        ImageAxes                 matlab.ui.control.UIAxes
    end


    properties (Access = private)
        OriginalImage;
        OriginalA;
        OriginalPhi;
        WorkImage;
        WorkA;
        WorkPhi;
        Size

    end

    methods (Access = private)

        function results = DrawImage(app);
            imshow(app.WorkImage,Parent=app.ImageAxes);
            if app.ActionButtonGroup.SelectedObject==app.ChangesinglefouierfunctionButton
                imshow(fftshift(log(app.WorkA)),log([min(app.WorkA,[],"all"),max(app.WorkA,[],"all")]),Parent=app.AmpAxes);
                hold(app.AmpAxes, 'on');
                x = 0;
                y = 0;
                if app.Size(1)/2 > app.YSpinner.Value
                    y = round(app.YSpinner.Value + app.Size(1)/2);
                else
                    y = round(app.YSpinner.Value - app.Size(1)/2);
                end
                if app.Size(2)/2 > app.XSpinner.Value
                    x = round(app.XSpinner.Value + app.Size(2)/2);
                else
                    x = round(app.XSpinner.Value - app.Size(2)/2);
                end
                plot(app.AmpAxes,x,y,'ro');
                app.AmpAxes.XLim =[0,app.Size(2)];
                app.AmpAxes.YLim =[0,app.Size(1)];
                hold(app.AmpAxes, 'off');
            else
                imshow(fftshift(log(app.WorkA)),log([min(app.WorkA,[],"all"),max(app.WorkA,[],"all")]),Parent=app.AmpAxes);
            end
            imshow(fftshift(app.WorkPhi),[-pi,pi],Parent=app.PhiAxes);
            app.PhiAxes.Position = app.AmpAxes.Position;
            app.PhiAxes.Position(1) = app.PhiAxes.Position(1)+449;

        end


        function results = ApplyTransition(app)
            app.WorkA = app.OriginalA;
            app.WorkPhi = app.OriginalPhi;
            if app.ActionButtonGroup.SelectedObject == app.ChangesinglefouierfunctionButton
                app.WorkA = app.OriginalA;
                app.WorkA(app.YSpinner.Value,app.XSpinner.Value) = exp(app.ValueSlider.Value);
            elseif app.ActionButtonGroup.SelectedObject == app.FiltrationButton
                f = 0;
                switch app.FilterTypeDropDown.ValueIndex
                    case 1
                        f = fspecial(app.FilterTypeDropDown.Value,[app.YsizeSpinner.Value,app.XsizeSpinner.Value]);
                    case 2
                        f= fspecial(app.FilterTypeDropDown.Value,app.RadiusSpinner.Value);
                    case 3
                        f = fspecial(app.FilterTypeDropDown.Value,[app.YsizeSpinner.Value,app.XsizeSpinner.Value],app.SigmaSlider.Value);
                end
                app.WorkA = app.WorkA .* abs(fft2(f,app.Size(1),app.Size(2)));
            else
                m = 0;
                k = app.SizeSlider.Value;
                if app.KernelShapeDropDown.ValueIndex ==1
                    m = ones(app.Size(1),app.Size(2));
                    m(k/2:end-k/2,:)= 0;
                    m(:,k/2:end-k/2)= 0;
                    
                else
                    if abs(k-min(app.Size))<8
                        k = k-8;
                    end
                    m = zeros(app.Size(1),app.Size(2));
                    f = fspecial("disk",k/2);
                    m((end/2-k/2):(end/2+k/2),(end/2-k/2):(end/2+k/2))=ceil(f);
                    m = fftshift(m);
                end
                app.WorkA = m.*app.WorkA;
                app.WorkPhi = m.*(app.WorkPhi+pi)-pi;
            end
            app.WorkImage = abs(ifft2(app.WorkA.*exp(1i*app.OriginalPhi)));
        end

        function results = MenageHiding(app,i)
            switch i
                case 1
                    app.RadiusSpinner.Visible = "off";
                    app.SigmaSlider.Visible = "off";
                    app.SigmaSliderLabel.Visible = "off";
                    app.RadiusSpinnerLabel.Visible = "off";
                    app.YsizeSpinner.Visible = "off";
                    app.YsizeSpinnerLabel.Visible = "off";
                    app.XsizeSpinner.Visible = "off";
                    app.XsizeSpinnerLabel.Visible= "off";
                    app.FilterTypeDropDown.Visible = "off";
                    app.FilterTypeDropDownLabel.Visible = "off";
                    app.ValueSlider.Visible = "on";
                    app.ValueSliderLabel.Visible = "on";
                    app.XSpinner.Visible = "on";
                    app.YSpinner.Visible = "on";
                    app.XSpinnerLabel.Visible = "on";
                    app.YSpinnerLabel.Visible = "on"
                    app.SizeSlider.Visible = "off";
                    app.SizeSliderLabel.Visible = "off";
                    app.KernelShapeDropDown.Visible = "off";
                    app.KernelShapeDropDownLabel.Visible = "off";
                case 2
                    app.RadiusSpinner.Visible = "off";
                    app.SigmaSlider.Visible = "off";
                    app.SigmaSliderLabel.Visible = "off";
                    app.RadiusSpinnerLabel.Visible = "off";
                    app.YsizeSpinner.Visible = "on";
                    app.YsizeSpinnerLabel.Visible = "on";
                    app.XsizeSpinner.Visible = "on";
                    app.XsizeSpinnerLabel.Visible= "on";
                    app.FilterTypeDropDown.Visible = "on";
                    app.FilterTypeDropDownLabel.Visible = "on";
                    app.ValueSlider.Visible = "off";
                    app.ValueSliderLabel.Visible = "off";
                    app.XSpinner.Visible = "off";
                    app.YSpinner.Visible = "off";
                    app.XSpinnerLabel.Visible = "off";
                    app.YSpinnerLabel.Visible = "off"
                    app.SizeSlider.Visible = "off";
                    app.SizeSliderLabel.Visible = "off";
                    app.KernelShapeDropDown.Visible = "off";
                    app.KernelShapeDropDownLabel.Visible = "off";

                case 3
                    app.RadiusSpinner.Visible = "off";
                    app.SigmaSlider.Visible = "off";
                    app.SigmaSliderLabel.Visible = "off";
                    app.RadiusSpinnerLabel.Visible = "off";
                    app.YsizeSpinner.Visible = "off";
                    app.YsizeSpinnerLabel.Visible = "off";
                    app.XsizeSpinner.Visible = "off";
                    app.XsizeSpinnerLabel.Visible= "off";
                    app.FilterTypeDropDown.Visible = "off";
                    app.FilterTypeDropDownLabel.Visible = "off";
                    app.ValueSlider.Visible = "off";
                    app.ValueSliderLabel.Visible = "off";
                    app.XSpinner.Visible = "off";
                    app.YSpinner.Visible = "off";
                    app.XSpinnerLabel.Visible = "off";
                    app.YSpinnerLabel.Visible = "off"
                    app.SizeSlider.Visible = "on";
                    app.SizeSliderLabel.Visible = "on";
                    app.KernelShapeDropDown.Visible = "on";
                    app.KernelShapeDropDownLabel.Visible = "on";
                    
            end
        end
    end


    % Callbacks that handle component events
    methods (Access = private)

        % Button pushed function: LoadButton
        function LoadButtonPushed(app, event)
            try
            [file, path] = uigetimagefile;
            if ~isempty(file)
                app.OriginalImage = rgb2gray(double(imread(file))/255);
                app.Size = size(app.OriginalImage);
                app.WorkImage = app.OriginalImage;
                app.YSpinner.Visible = "on";
                app.ResetButton.Visible = "on";
                app.XSpinner.Visible = "on";
                app.ActionButtonGroup.Visible= "on";
                app.ValueSlider.Visible= "on";
                app.ImageAxes.Visible = "on";
                app.PhiAxes.Visible="on";
                app.AmpAxes.Visible = "on";
                app.YSpinnerLabel.Visible = "on";
                app.XSpinnerLabel.Visible = "on";
                app.ValueSliderLabel.Visible = "on";
                fim = fft2(app.WorkImage);
                app.OriginalA = abs(fim);
                app.OriginalPhi = angle(fim);
                app.WorkA = app.OriginalA;
                app.WorkPhi = app.OriginalPhi;
                app.ValueSlider.Limits = log([min(app.WorkA,[],"all"),max(app.WorkA,[],"all")]);
                app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
                app.XSpinner.Limits = [1,app.Size(2)];
                app.YSpinner.Limits = [1,app.Size(1)];
                app.SizeSlider.Limits = [4,min(app.Size)];
                


                app.ApplyTransition;
                app.DrawImage;
            end
            catch e
                uialert(app.UIFigure, e.message, "Error while loading image",Interpreter="html");
            end
        end

        % Value changing function: YSpinner
        function YSpinnerValueChanging(app, event)
            changingValue = event.Value;
            app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changed function: YSpinner
        function YSpinnerValueChanged(app, event)
            value = app.YSpinner.Value;
            app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changed function: XSpinner
        function XSpinnerValueChanged(app, event)
            value = app.XSpinner.Value;
            app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changing function: XSpinner
        function XSpinnerValueChanging(app, event)
            changingValue = event.Value;
            app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changed function: ValueSlider
        function ValueSliderValueChanged(app, event)
            value = app.ValueSlider.Value;
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changing function: ValueSlider
        function ValueSliderValueChanging(app, event)
            changingValue = event.Value;
            app.ApplyTransition;
            app.DrawImage;
        end

        % Button pushed function: ResetButton
        function ResetButtonPushed(app, event)
            app.WorkA = app.OriginalA;
            app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            app.ApplyTransition;
            app.DrawImage;
        end

        % Selection changed function: ActionButtonGroup
        function ActionButtonGroupSelectionChanged(app, event)
            selectedButton = app.ActionButtonGroup.SelectedObject;
            app.WorkA = app.OriginalA;
            app.WorkPhi = app.OriginalPhi;
            if app.ActionButtonGroup.SelectedObject == app.ChangesinglefouierfunctionButton
                app.MenageHiding(1);
                app.YSpinner.Value = 1;
                app.XSpinner.Value = 1;
                app.ValueSlider.Limits = log([min(app.WorkA,[],"all"),max(app.WorkA,[],"all")]);
                app.ValueSlider.Value = log(app.WorkA(app.YSpinner.Value,app.XSpinner.Value));
            elseif app.ActionButtonGroup.SelectedObject == app.FiltrationButton
                app.MenageHiding(2);
                app.FilterTypeDropDown.Value = 'average';
                app.XsizeSpinner.Value = 3;
                app.YsizeSpinner.Value = 3;
                
            else
                app.MenageHiding(3);
                app.KernelShapeDropDown.Value = 'square';
            end
            app.ApplyTransition;
            app.DrawImage;
        end

        % Value changed function: FilterTypeDropDown
        function FilterTypeDropDownValueChanged(app, event)
            value = app.FilterTypeDropDown.Value;
            app.WorkA = app.OriginalA;
            switch app.FilterTypeDropDown.ValueIndex
                case 1
                    app.RadiusSpinner.Visible = "off";
                    app.SigmaSlider.Visible = "off";
                    app.SigmaSliderLabel.Visible = "off";
                    app.RadiusSpinnerLabel.Visible = "off";
                    app.YsizeSpinner.Visible = "on";
                    app.YsizeSpinnerLabel.Visible = "on";
                    app.XsizeSpinner.Visible = "on";
                    app.XsizeSpinnerLabel.Visible= "on";
                    app.XsizeSpinner.Value = 3;
                    app.YsizeSpinner.Value = 3;
                case 2
                    app.RadiusSpinner.Visible = "on";
                    app.SigmaSlider.Visible = "off";
                    app.SigmaSliderLabel.Visible = "off";
                    app.RadiusSpinnerLabel.Visible = "on";
                    app.YsizeSpinner.Visible = "off";
                    app.YsizeSpinnerLabel.Visible = "off";
                    app.XsizeSpinner.Visible = "off";
                    app.XsizeSpinnerLabel.Visible= "off";
                    app.RadiusSpinner.Value = 1;
                case 3
                    app.RadiusSpinner.Visible = "off";
                    app.SigmaSlider.Visible = "on";
                    app.SigmaSliderLabel.Visible = "on";
                    app.RadiusSpinnerLabel.Visible = "off";
                    app.YsizeSpinner.Visible = "on";
                    app.YsizeSpinnerLabel.Visible = "on";
                    app.XsizeSpinner.Visible = "on";
                    app.XsizeSpinnerLabel.Visible= "on";
                    app.XsizeSpinner.Value = 3;
                    app.YsizeSpinner.Value = 3;
                    app.SigmaSlider.Value = 1;
            end
            app.ApplyTransition;
            app.DrawImage;
        end

        % Callback function: KernelShapeDropDown, RadiusSpinner, 
        % ...and 4 other components
        function RadiusSpinnerValueChanged(app, event)
            app.ApplyTransition;
            app.DrawImage;
            
        end

        % Callback function: SizeSlider, SizeSlider
        function SizeSliderValueChanged(app, event)
            value = app.SizeSlider.Value;
            app.SizeSlider.Value = round(value/4)*4;
            app.ApplyTransition;
            app.DrawImage;
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [100 100 1217 890];
            app.UIFigure.Name = 'MATLAB App';

            % Create ImageAxes
            app.ImageAxes = uiaxes(app.UIFigure);
            title(app.ImageAxes, 'Image')
            app.ImageAxes.XTick = [];
            app.ImageAxes.YTick = [];
            app.ImageAxes.ZTick = [];
            app.ImageAxes.Visible = 'off';
            app.ImageAxes.Position = [2 334 873 557];

            % Create AmpAxes
            app.AmpAxes = uiaxes(app.UIFigure);
            title(app.AmpAxes, 'Amplitude Spectrum')
            app.AmpAxes.XTick = [];
            app.AmpAxes.YTick = [];
            app.AmpAxes.ZTick = [];
            app.AmpAxes.Visible = 'off';
            app.AmpAxes.Position = [1 1 440 340];

            % Create PhiAxes
            app.PhiAxes = uiaxes(app.UIFigure);
            title(app.PhiAxes, 'Phase Spectrum')
            app.PhiAxes.XTick = [];
            app.PhiAxes.YTick = [];
            app.PhiAxes.ZTick = [];
            app.PhiAxes.Visible = 'off';
            app.PhiAxes.Position = [450 1 440 340];

            % Create LoadButton
            app.LoadButton = uibutton(app.UIFigure, 'push');
            app.LoadButton.ButtonPushedFcn = createCallbackFcn(app, @LoadButtonPushed, true);
            app.LoadButton.Position = [919 846 100 23];
            app.LoadButton.Text = 'Load';

            % Create ResetButton
            app.ResetButton = uibutton(app.UIFigure, 'push');
            app.ResetButton.ButtonPushedFcn = createCallbackFcn(app, @ResetButtonPushed, true);
            app.ResetButton.Visible = 'off';
            app.ResetButton.Position = [1019 845 100 23];
            app.ResetButton.Text = 'Reset';

            % Create ActionButtonGroup
            app.ActionButtonGroup = uibuttongroup(app.UIFigure);
            app.ActionButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ActionButtonGroupSelectionChanged, true);
            app.ActionButtonGroup.Title = 'Action';
            app.ActionButtonGroup.Visible = 'off';
            app.ActionButtonGroup.Position = [920 704 123 125];

            % Create ChangesinglefouierfunctionButton
            app.ChangesinglefouierfunctionButton = uitogglebutton(app.ActionButtonGroup);
            app.ChangesinglefouierfunctionButton.Text = {'Change single '; 'fouier function'};
            app.ChangesinglefouierfunctionButton.Position = [14 57 100 37];
            app.ChangesinglefouierfunctionButton.Value = true;

            % Create FiltrationButton
            app.FiltrationButton = uitogglebutton(app.ActionButtonGroup);
            app.FiltrationButton.Text = 'Filtration';
            app.FiltrationButton.Position = [15 35 100 23];

            % Create CompressionButton
            app.CompressionButton = uitogglebutton(app.ActionButtonGroup);
            app.CompressionButton.Text = 'Compression';
            app.CompressionButton.Position = [15 13 100 23];

            % Create XSpinnerLabel
            app.XSpinnerLabel = uilabel(app.UIFigure);
            app.XSpinnerLabel.HorizontalAlignment = 'right';
            app.XSpinnerLabel.Visible = 'off';
            app.XSpinnerLabel.Position = [940 669 25 22];
            app.XSpinnerLabel.Text = 'X';

            % Create XSpinner
            app.XSpinner = uispinner(app.UIFigure);
            app.XSpinner.ValueChangingFcn = createCallbackFcn(app, @XSpinnerValueChanging, true);
            app.XSpinner.Limits = [1 2];
            app.XSpinner.ValueChangedFcn = createCallbackFcn(app, @XSpinnerValueChanged, true);
            app.XSpinner.Visible = 'off';
            app.XSpinner.Position = [980 669 100 22];
            app.XSpinner.Value = 1;

            % Create YSpinnerLabel
            app.YSpinnerLabel = uilabel(app.UIFigure);
            app.YSpinnerLabel.HorizontalAlignment = 'right';
            app.YSpinnerLabel.Visible = 'off';
            app.YSpinnerLabel.Position = [940 640 25 22];
            app.YSpinnerLabel.Text = 'Y';

            % Create YSpinner
            app.YSpinner = uispinner(app.UIFigure);
            app.YSpinner.ValueChangingFcn = createCallbackFcn(app, @YSpinnerValueChanging, true);
            app.YSpinner.Limits = [1 2];
            app.YSpinner.ValueChangedFcn = createCallbackFcn(app, @YSpinnerValueChanged, true);
            app.YSpinner.Visible = 'off';
            app.YSpinner.Position = [980 640 100 22];
            app.YSpinner.Value = 1;

            % Create ValueSliderLabel
            app.ValueSliderLabel = uilabel(app.UIFigure);
            app.ValueSliderLabel.HorizontalAlignment = 'right';
            app.ValueSliderLabel.Visible = 'off';
            app.ValueSliderLabel.Position = [920 612 35 22];
            app.ValueSliderLabel.Text = 'Value';

            % Create ValueSlider
            app.ValueSlider = uislider(app.UIFigure);
            app.ValueSlider.MajorTicks = [];
            app.ValueSlider.MajorTickLabels = {''};
            app.ValueSlider.ValueChangedFcn = createCallbackFcn(app, @ValueSliderValueChanged, true);
            app.ValueSlider.ValueChangingFcn = createCallbackFcn(app, @ValueSliderValueChanging, true);
            app.ValueSlider.Visible = 'off';
            app.ValueSlider.Position = [976 621 132 3];

            % Create FilterTypeDropDownLabel
            app.FilterTypeDropDownLabel = uilabel(app.UIFigure);
            app.FilterTypeDropDownLabel.HorizontalAlignment = 'right';
            app.FilterTypeDropDownLabel.Visible = 'off';
            app.FilterTypeDropDownLabel.Position = [925 669 61 22];
            app.FilterTypeDropDownLabel.Text = 'Filter Type';

            % Create FilterTypeDropDown
            app.FilterTypeDropDown = uidropdown(app.UIFigure);
            app.FilterTypeDropDown.Items = {'average', 'disk', 'gaussian'};
            app.FilterTypeDropDown.ValueChangedFcn = createCallbackFcn(app, @FilterTypeDropDownValueChanged, true);
            app.FilterTypeDropDown.Visible = 'off';
            app.FilterTypeDropDown.Position = [1001 669 100 22];
            app.FilterTypeDropDown.Value = 'average';

            % Create XsizeSpinnerLabel
            app.XsizeSpinnerLabel = uilabel(app.UIFigure);
            app.XsizeSpinnerLabel.HorizontalAlignment = 'right';
            app.XsizeSpinnerLabel.Visible = 'off';
            app.XsizeSpinnerLabel.Position = [949 633 38 22];
            app.XsizeSpinnerLabel.Text = 'X size';

            % Create XsizeSpinner
            app.XsizeSpinner = uispinner(app.UIFigure);
            app.XsizeSpinner.Step = 2;
            app.XsizeSpinner.Limits = [3 51];
            app.XsizeSpinner.ValueChangedFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.XsizeSpinner.Visible = 'off';
            app.XsizeSpinner.Position = [1002 633 100 22];
            app.XsizeSpinner.Value = 3;

            % Create YsizeSpinnerLabel
            app.YsizeSpinnerLabel = uilabel(app.UIFigure);
            app.YsizeSpinnerLabel.HorizontalAlignment = 'right';
            app.YsizeSpinnerLabel.Visible = 'off';
            app.YsizeSpinnerLabel.Position = [952 600 37 22];
            app.YsizeSpinnerLabel.Text = 'Y size';

            % Create YsizeSpinner
            app.YsizeSpinner = uispinner(app.UIFigure);
            app.YsizeSpinner.Step = 2;
            app.YsizeSpinner.Limits = [3 51];
            app.YsizeSpinner.ValueChangedFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.YsizeSpinner.Visible = 'off';
            app.YsizeSpinner.Position = [1004 600 100 22];
            app.YsizeSpinner.Value = 3;

            % Create SigmaSliderLabel
            app.SigmaSliderLabel = uilabel(app.UIFigure);
            app.SigmaSliderLabel.HorizontalAlignment = 'right';
            app.SigmaSliderLabel.Visible = 'off';
            app.SigmaSliderLabel.Position = [923 567 39 22];
            app.SigmaSliderLabel.Text = 'Sigma';

            % Create SigmaSlider
            app.SigmaSlider = uislider(app.UIFigure);
            app.SigmaSlider.Limits = [1 10];
            app.SigmaSlider.ValueChangedFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.SigmaSlider.ValueChangingFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.SigmaSlider.Visible = 'off';
            app.SigmaSlider.Position = [983 576 114 3];
            app.SigmaSlider.Value = 1;

            % Create RadiusSpinnerLabel
            app.RadiusSpinnerLabel = uilabel(app.UIFigure);
            app.RadiusSpinnerLabel.HorizontalAlignment = 'right';
            app.RadiusSpinnerLabel.Visible = 'off';
            app.RadiusSpinnerLabel.Position = [948 633 42 22];
            app.RadiusSpinnerLabel.Text = 'Radius';

            % Create RadiusSpinner
            app.RadiusSpinner = uispinner(app.UIFigure);
            app.RadiusSpinner.Limits = [1 50];
            app.RadiusSpinner.ValueChangedFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.RadiusSpinner.Visible = 'off';
            app.RadiusSpinner.Position = [1005 633 100 22];
            app.RadiusSpinner.Value = 1;

            % Create KernelShapeDropDownLabel
            app.KernelShapeDropDownLabel = uilabel(app.UIFigure);
            app.KernelShapeDropDownLabel.HorizontalAlignment = 'right';
            app.KernelShapeDropDownLabel.Visible = 'off';
            app.KernelShapeDropDownLabel.Position = [909 669 78 22];
            app.KernelShapeDropDownLabel.Text = 'Kernel Shape';

            % Create KernelShapeDropDown
            app.KernelShapeDropDown = uidropdown(app.UIFigure);
            app.KernelShapeDropDown.Items = {'square', 'disk'};
            app.KernelShapeDropDown.ValueChangedFcn = createCallbackFcn(app, @RadiusSpinnerValueChanged, true);
            app.KernelShapeDropDown.Visible = 'off';
            app.KernelShapeDropDown.Position = [1002 669 100 22];
            app.KernelShapeDropDown.Value = 'square';

            % Create SizeSliderLabel
            app.SizeSliderLabel = uilabel(app.UIFigure);
            app.SizeSliderLabel.HorizontalAlignment = 'right';
            app.SizeSliderLabel.Visible = 'off';
            app.SizeSliderLabel.Position = [918 633 28 22];
            app.SizeSliderLabel.Text = 'Size';

            % Create SizeSlider
            app.SizeSlider = uislider(app.UIFigure);
            app.SizeSlider.Limits = [1 1000];
            app.SizeSlider.MajorTicks = [];
            app.SizeSlider.ValueChangedFcn = createCallbackFcn(app, @SizeSliderValueChanged, true);
            app.SizeSlider.ValueChangingFcn = createCallbackFcn(app, @SizeSliderValueChanged, true);
            app.SizeSlider.Visible = 'off';
            app.SizeSlider.Position = [967 642 150 3];
            app.SizeSlider.Value = 100;

            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = Extra_fourier

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end