classdef projekt_kb < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                        matlab.ui.Figure
        PlikMenu                        matlab.ui.container.Menu
        WczytajobrazMenu                matlab.ui.container.Menu
        ZapiszkopieobrazuMenu           matlab.ui.container.Menu
        ZamknijMenu                     matlab.ui.container.Menu
        FiltryMenu                      matlab.ui.container.Menu
        RGBtoGRAYMenu                   matlab.ui.container.Menu
        GRAYTORGBMenu                   matlab.ui.container.Menu
        ZAAWANSOWANEMenu                matlab.ui.container.Menu
        AVERAGEMenu                     matlab.ui.container.Menu
        SOBELMenu                       matlab.ui.container.Menu
        CANNYMenu                       matlab.ui.container.Menu
        LAPLACIANMenu                   matlab.ui.container.Menu
        DetektorcechMenu                matlab.ui.container.Menu
        KAZEMenu                        matlab.ui.container.Menu
        FASTMenu                        matlab.ui.container.Menu
        HARRISMenu                      matlab.ui.container.Menu
        MSERELIPSAMenu                  matlab.ui.container.Menu
        KrawedziowanieMenu              matlab.ui.container.Menu
        VerticalMenu                    matlab.ui.container.Menu
        HorizontalMenu                  matlab.ui.container.Menu
        DiagonalMenu                    matlab.ui.container.Menu
        LaplacianMenu                   matlab.ui.container.Menu
        SubstractionMenu                matlab.ui.container.Menu
        KluczowanieMenu                 matlab.ui.container.Menu
        ProbkowanieMenu                 matlab.ui.container.Menu
        PodmianaMenu                    matlab.ui.container.Menu
        ProjektAIPOC134891_Kamil_BrzozowskiLabel  matlab.ui.control.Label
        ParametrywczytanegoobrazuLabel  matlab.ui.control.Label
        szerokoscLabel                  matlab.ui.control.Label
        wysokoscLabel                   matlab.ui.control.Label
        liczbaskladowychLabel           matlab.ui.control.Label
        Button                          matlab.ui.control.Button
        Button_2                        matlab.ui.control.Button
        SkalowanieLabel                 matlab.ui.control.Label
        RGBLabel                        matlab.ui.control.Label
        PoczatkowewartosciskladowychRGBLabel  matlab.ui.control.Label
        RLabel                          matlab.ui.control.Label
        GLabel                          matlab.ui.control.Label
        BLabel                          matlab.ui.control.Label
        ProgowanieSliderLabel           matlab.ui.control.Label
        ProgowanieSlider                matlab.ui.control.Slider
        RESETButton                     matlab.ui.control.Button
        UsuwaniefiltrowLabel            matlab.ui.control.Label
        OperacjepodstawoweLabel         matlab.ui.control.Label
        JasnoscSliderLabel              matlab.ui.control.Label
        JasnoscSlider                   matlab.ui.control.Slider
        RSliderLabel                    matlab.ui.control.Label
        RSlider                         matlab.ui.control.Slider
        BSliderLabel                    matlab.ui.control.Label
        BSlider                         matlab.ui.control.Slider
        GSlider_2Label                  matlab.ui.control.Label
        GSlider_2                       matlab.ui.control.Slider
        ModyfikacjaskadowychRGBLabel    matlab.ui.control.Label
        GUILabel                        matlab.ui.control.Label
        DarkmodeSwitchLabel             matlab.ui.control.Label
        DarkmodeSwitch                  matlab.ui.control.Switch
        UIAxes                          matlab.ui.control.UIAxes
        UIAxes2                         matlab.ui.control.UIAxes
    end

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

        % Menu selected function: ZamknijMenu
        function ZamknijMenuSelected(app, event)
            close(app.UIFigure);
        end

        % Menu selected function: WczytajobrazMenu
        function WczytajobrazMenuSelected(app, event)
            global obraz obrazc;
            [file,path] = uigetfile('*.jpg;*.png;*.bmp',"Wczytaj obraz..");
            obraz = imread([path,file]);
            obrazc = obraz;

            [x,y,z] = size(obraz)
            set(app.szerokoscLabel,'Text',['szerokosc = ',num2str(y)]);
            set(app.wysokoscLabel,'Text',['wysokosc = ',num2str(x)]);
            set(app.liczbaskladowychLabel,'Text',['liczba skladowych = ',num2str(z)]);

            r = obraz(:,:,1);
            g = obraz(:,:,2);
            b = obraz(:,:,3);

            r = sprintf('%d', r(1, 1));
            g = sprintf('%d', g(1, 1));
            b = sprintf('%d', b(1, 1));


            set(app.RLabel,'Text',['R: ',r]);
            set(app.GLabel,'Text',['G: ',g]);
            set(app.BLabel,'Text',['B: ',b]);

            %set(app.UIAxes,'Position',[1,353,y,x]);
            imshow(obraz,'Parent',app.UIAxes);
            imshow(obrazc,'Parent',app.UIAxes2);
            
            %set(app.UIAxes2,'Position',[436,359,y,x]);

        end

        % Menu selected function: RGBtoGRAYMenu
        function RGBtoGRAYMenuSelected(app, event)
        global obraz obrazc;  
        obraz = rgb2gray(obrazc);
        imshow(obraz,'Parent',app.UIAxes2);
        end

        % Menu selected function: GRAYTORGBMenu
        function GRAYTORGBMenuSelected(app, event)
        global obraz obrazc;
        obraz = obrazc;
        imshow(obraz,'Parent',app.UIAxes2);
        end

        % Menu selected function: ZapiszkopieobrazuMenu
        function ZapiszkopieobrazuMenuSelected(app, event)
        global obraz obrazc;
        [file,path] = uiputfile('*.jpg','Zapisz kopie obrazu');
        imwrite(obraz,[path,file]);
        end

        % Button pushed function: Button
        function ButtonPushed(app, event)
            global obraz
            obraz = imresize(obraz,1.1);
            [x,y,z] = size(obraz)
            set(app.szerokoscLabel,'Text',['szerokosc = ',num2str(y)]);
            set(app.wysokoscLabel,'Text',['wysokosc = ',num2str(x)]);
            set(app.liczbaskladowychLabel,'Text',['liczba skladowych = ',num2str(z)]);
            %set(app.UIAxes,'Position',[1,353,y,x]);
            imshow(obraz,'Parent',app.UIAxes);
        end

        % Button pushed function: Button_2
        function Button_2Pushed(app, event)
            global obraz
            obraz = imresize(obraz,0.9);
            [x,y,z] = size(obraz)
            set(app.szerokoscLabel,'Text',['szerokosc = ',num2str(y)]);
            set(app.wysokoscLabel,'Text',['wysokosc = ',num2str(x)]);
            set(app.liczbaskladowychLabel,'Text',['liczba skladowych = ',num2str(z)]);
            %set(app.UIAxes,'Position',[1,353,y,x]);
            imshow(obraz,'Parent',app.UIAxes);
        end

        % Value changing function: ProgowanieSlider
        function ProgowanieSliderValueChanging(app, event)
            global obraz obrazc
            changingValue = event.Value;

            obraz = rgb2gray(obrazc);
            [rx,ry] = size(obraz);
            for(x=1:rx)
                for(y=1:ry)
                    if(obraz(x,y)<changingValue)
                        obraz(x,y) = 0;
                    end
                end
            end
            imshow(obraz,'Parent',app.UIAxes2);
        end

        % Button pushed function: RESETButton
        function RESETButtonPushed(app, event)
            global obraz obrazc;
            imshow(obrazc,'Parent',app.UIAxes2);            
        end

        % Value changing function: JasnoscSlider
        function JasnoscSliderValueChanging(app, event)
            global obraz obrazc
            changingValue = event.Value;
            jasnosc = changingValue;
            obraz = obrazc * jasnosc;
            obraz(obraz < 0) = 0;
            obraz(obraz > 255) = 255;
            imshow(uint8(obraz), 'Parent', app.UIAxes2);
        end

        % Value changing function: RSlider
        function RSliderValueChanging(app, event)
            global obraz obrazc
            changingValue = event.Value;
            obraz(:, :, 1) = obrazc(:, :, 1) * changingValue;
            obraz(obraz < 0) = 0;
            obraz(obraz > 255) = 255;
            imshow(uint8(obraz), 'Parent', app.UIAxes2);
        end

        % Value changing function: GSlider_2
        function GSlider_2ValueChanging(app, event)
            global obraz obrazc;
            changingValue = event.Value;
            obraz(:, :, 2) = obrazc(:, :, 2) * changingValue;
            obraz(obraz < 0) = 0;
            obraz(obraz > 255) = 255;
            imshow(uint8(obraz), 'Parent', app.UIAxes2);
        end

        % Value changing function: BSlider
        function BSliderValueChanging(app, event)
            global obraz obrazc
            changingValue = event.Value;
            obraz(:, :, 3) = obrazc(:, :, 3) * changingValue;
            obraz(obraz < 0) = 0;
            obraz(obraz > 255) = 255;
            imshow(uint8(obraz), 'Parent', app.UIAxes2); 
        end

        % Menu selected function: AVERAGEMenu
        function AVERAGEMenuSelected(app, event)
            global obraz obrazc
            f = fspecial('average',[5,5]);
            average = imfilter(obraz,f,'replicate');
            imshow(average,'Parent',app.UIAxes2);
        end

        % Menu selected function: SOBELMenu
        function SOBELMenuSelected(app, event)
            global obraz obrazc
            f = fspecial('sobel');
            sobel = imfilter(obraz,f,'replicate');
            imshow(sobel,'Parent',app.UIAxes2);
        end

        % Menu selected function: CANNYMenu
        function CANNYMenuSelected(app, event)
            global obraz obrazc
            f = rgb2gray(obraz);
            canny = edge(f,'canny');
            imshow(canny,'Parent',app.UIAxes2);            
        end

        % Menu selected function: LAPLACIANMenu
        function LAPLACIANMenuSelected(app, event)
            global obraz obrazc
            f = fspecial('laplacian',0.3);
            lap = imfilter(obraz,f,'replicate');
            imshow(lap,'Parent',app.UIAxes2);
        end

        % Menu selected function: KAZEMenu
        function KAZEMenuSelected(app, event)
            global obraz
            points = detectKAZEFeatures(rgb2gray(obraz));
            imshow(obraz);
            hold on;
            plot(selectStrongest(points, 30)); 
            hold off;    
        end

        % Menu selected function: FASTMenu
        function FASTMenuSelected(app, event)
            global obraz
            corners = detectFASTFeatures(rgb2gray(obraz));
            imshow(obraz);
            hold on;
            plot(corners.selectStrongest(30));
            hold off;            
        end

        % Menu selected function: HARRISMenu
        function HARRISMenuSelected(app, event)
            global obraz
            corners = detectHarrisFeatures(rgb2gray(obraz));
            imshow(obraz);
            hold on;
            plot(corners.selectStrongest(50)); 
            hold off;            
        end

        % Menu selected function: MSERELIPSAMenu
        function MSERELIPSAMenuSelected(app, event)
            global obraz
            regions = detectMSERFeatures(rgb2gray(obraz));
            imshow(obraz);
            hold on;
            plot(regions);
            hold off;            
        end

        % Menu selected function: VerticalMenu
        function VerticalMenuSelected(app, event)
            global obraz obraz_gray
            obraz_gray=rgb2gray(obraz);
            verticalMask = [-1, 0, 1; -1, 0, 1; -1, 0, 1];
            verticalEdges = conv2(double(obraz_gray), verticalMask, 'same');
            imshow(verticalEdges,'Parent',app.UIAxes2);            
        end

        % Menu selected function: HorizontalMenu
        function HorizontalMenuSelected(app, event)
            global obraz obraz_gray
            obraz_gray=rgb2gray(obraz);
            horizontalMask = [-1, -1, -1; 0, 0, 0; 1, 1, 1];
            horizontalEdges = conv2(double(obraz_gray), horizontalMask, 'same');
            imshow(horizontalEdges,'Parent',app.UIAxes2);            
        end

        % Menu selected function: DiagonalMenu
        function DiagonalMenuSelected(app, event)
            global obraz obraz_gray
            obraz_gray=rgb2gray(obraz);
            diagonalMask = [-1, -1, 0; -1, 0, 1; 0, 1, 1];
            diagonalEdges = conv2(double(obraz_gray), diagonalMask, 'same');
            imshow(diagonalEdges,'Parent',app.UIAxes2);            
        end

        % Menu selected function: LaplacianMenu
        function LaplacianMenuSelected(app, event)
            global obraz obraz_gray
            obraz_gray=rgb2gray(obraz);
            laplacianMask = [0, 1, 0; 1, -4, 1; 0, 1, 0];
            laplacianEdges = conv2(double(obraz_gray), laplacianMask, 'same');
            imshow(laplacianEdges,'Parent',app.UIAxes2);            
        end

        % Menu selected function: SubstractionMenu
        function SubstractionMenuSelected(app, event)
            global obraz obraz_gray
            obraz_gray=rgb2gray(obraz);
            verticalMask = [-1, 0, 1; -1, 0, 1; -1, 0, 1];
            horizontalMask = [-1, -1, -1; 0, 0, 0; 1, 1, 1];
            myMask = verticalMask - horizontalMask;
            myEdges = conv2(double(obraz_gray), myMask, 'same');
            imshow(myEdges,'Parent',app.UIAxes2);            
        end

        % Menu selected function: ProbkowanieMenu
        function ProbkowanieMenuSelected(app, event)
            global obraz Tab;
            Tab=impixel(obraz);
            max_r=max(Tab(:,1));
            min_r=min(Tab(:,1));
            max_g=max(Tab(:,2));
            min_g=min(Tab(:,2));
            max_b=max(Tab(:,3));
            min_b=min(Tab(:,3));            
            [rows, cols, ~] = size(obraz);
            for i = 1:rows
                for j = 1:cols
                    if obraz(i, j, 1) >= min_r && obraz(i, j, 1) <= max_r && obraz(i, j, 2) >= min_g && obraz(i, j, 2) <= max_g && obraz(i, j, 3) >= min_b && obraz(i, j, 3) <= max_b
                        obraz(i, j, :) = [0, 0, 0];
                    end
                end
            end
            
            imshow(obraz, 'Parent', app.UIAxes2);            
        end

        % Menu selected function: PodmianaMenu
        function PodmianaMenuSelected(app, event)
            global obraz;
            [file,track]=uigetfile('*.jpg;*.png;*.bmp;*.jpeg','Open image');
            image=imread([track,file]);
            tlo = image;
            
            [rows, cols, ~] = size(obraz);
            
            for i = 1:rows
                for j = 1:cols
                    if obraz(i, j, 1) == 0 && obraz(i, j, 2) == 0 && obraz(i, j, 3) == 0
                        obraz(i, j, :) = tlo(i, j, :);
                    end
                end
            end
            imshow(obraz, 'Parent', app.UIAxes2);            
        end

        % Value changed function: DarkmodeSwitch
        function DarkmodeSwitchValueChanged(app, event)
            value = app.DarkmodeSwitch.Value;
            if strcmp(value, 'On')
                set(app.UIFigure, 'Color', [0.7, 0.7, 0.7]);
            else
                set(app.UIFigure, 'Color', [1, 1, 1]);
            end
        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.Color = [1 1 1];
            app.UIFigure.Position = [100 100 1144 699];
            app.UIFigure.Name = 'MATLAB App';

            % Create PlikMenu
            app.PlikMenu = uimenu(app.UIFigure);
            app.PlikMenu.Text = 'Plik';

            % Create WczytajobrazMenu
            app.WczytajobrazMenu = uimenu(app.PlikMenu);
            app.WczytajobrazMenu.MenuSelectedFcn = createCallbackFcn(app, @WczytajobrazMenuSelected, true);
            app.WczytajobrazMenu.Text = 'Wczytaj obraz';

            % Create ZapiszkopieobrazuMenu
            app.ZapiszkopieobrazuMenu = uimenu(app.PlikMenu);
            app.ZapiszkopieobrazuMenu.MenuSelectedFcn = createCallbackFcn(app, @ZapiszkopieobrazuMenuSelected, true);
            app.ZapiszkopieobrazuMenu.Text = 'Zapisz kopie obrazu';

            % Create ZamknijMenu
            app.ZamknijMenu = uimenu(app.PlikMenu);
            app.ZamknijMenu.MenuSelectedFcn = createCallbackFcn(app, @ZamknijMenuSelected, true);
            app.ZamknijMenu.Text = 'Zamknij';

            % Create FiltryMenu
            app.FiltryMenu = uimenu(app.UIFigure);
            app.FiltryMenu.Text = 'Filtry';

            % Create RGBtoGRAYMenu
            app.RGBtoGRAYMenu = uimenu(app.FiltryMenu);
            app.RGBtoGRAYMenu.MenuSelectedFcn = createCallbackFcn(app, @RGBtoGRAYMenuSelected, true);
            app.RGBtoGRAYMenu.Text = 'RGB to GRAY';

            % Create GRAYTORGBMenu
            app.GRAYTORGBMenu = uimenu(app.FiltryMenu);
            app.GRAYTORGBMenu.MenuSelectedFcn = createCallbackFcn(app, @GRAYTORGBMenuSelected, true);
            app.GRAYTORGBMenu.Text = 'GRAY TO RGB';

            % Create ZAAWANSOWANEMenu
            app.ZAAWANSOWANEMenu = uimenu(app.FiltryMenu);
            app.ZAAWANSOWANEMenu.Text = 'ZAAWANSOWANE';

            % Create AVERAGEMenu
            app.AVERAGEMenu = uimenu(app.ZAAWANSOWANEMenu);
            app.AVERAGEMenu.MenuSelectedFcn = createCallbackFcn(app, @AVERAGEMenuSelected, true);
            app.AVERAGEMenu.Text = 'AVERAGE';

            % Create SOBELMenu
            app.SOBELMenu = uimenu(app.ZAAWANSOWANEMenu);
            app.SOBELMenu.MenuSelectedFcn = createCallbackFcn(app, @SOBELMenuSelected, true);
            app.SOBELMenu.Text = 'SOBEL';

            % Create CANNYMenu
            app.CANNYMenu = uimenu(app.ZAAWANSOWANEMenu);
            app.CANNYMenu.MenuSelectedFcn = createCallbackFcn(app, @CANNYMenuSelected, true);
            app.CANNYMenu.Text = 'CANNY';

            % Create LAPLACIANMenu
            app.LAPLACIANMenu = uimenu(app.ZAAWANSOWANEMenu);
            app.LAPLACIANMenu.MenuSelectedFcn = createCallbackFcn(app, @LAPLACIANMenuSelected, true);
            app.LAPLACIANMenu.Text = 'LAPLACIAN';

            % Create DetektorcechMenu
            app.DetektorcechMenu = uimenu(app.UIFigure);
            app.DetektorcechMenu.Text = 'Detektor cech';

            % Create KAZEMenu
            app.KAZEMenu = uimenu(app.DetektorcechMenu);
            app.KAZEMenu.MenuSelectedFcn = createCallbackFcn(app, @KAZEMenuSelected, true);
            app.KAZEMenu.Text = 'KAZE';

            % Create FASTMenu
            app.FASTMenu = uimenu(app.DetektorcechMenu);
            app.FASTMenu.MenuSelectedFcn = createCallbackFcn(app, @FASTMenuSelected, true);
            app.FASTMenu.Text = 'FAST';

            % Create HARRISMenu
            app.HARRISMenu = uimenu(app.DetektorcechMenu);
            app.HARRISMenu.MenuSelectedFcn = createCallbackFcn(app, @HARRISMenuSelected, true);
            app.HARRISMenu.Text = 'HARRIS';

            % Create MSERELIPSAMenu
            app.MSERELIPSAMenu = uimenu(app.DetektorcechMenu);
            app.MSERELIPSAMenu.MenuSelectedFcn = createCallbackFcn(app, @MSERELIPSAMenuSelected, true);
            app.MSERELIPSAMenu.Text = 'MSER ELIPSA';

            % Create KrawedziowanieMenu
            app.KrawedziowanieMenu = uimenu(app.UIFigure);
            app.KrawedziowanieMenu.Text = 'Krawedziowanie';

            % Create VerticalMenu
            app.VerticalMenu = uimenu(app.KrawedziowanieMenu);
            app.VerticalMenu.MenuSelectedFcn = createCallbackFcn(app, @VerticalMenuSelected, true);
            app.VerticalMenu.Text = 'Vertical';

            % Create HorizontalMenu
            app.HorizontalMenu = uimenu(app.KrawedziowanieMenu);
            app.HorizontalMenu.MenuSelectedFcn = createCallbackFcn(app, @HorizontalMenuSelected, true);
            app.HorizontalMenu.Text = 'Horizontal';

            % Create DiagonalMenu
            app.DiagonalMenu = uimenu(app.KrawedziowanieMenu);
            app.DiagonalMenu.MenuSelectedFcn = createCallbackFcn(app, @DiagonalMenuSelected, true);
            app.DiagonalMenu.Text = 'Diagonal';

            % Create LaplacianMenu
            app.LaplacianMenu = uimenu(app.KrawedziowanieMenu);
            app.LaplacianMenu.MenuSelectedFcn = createCallbackFcn(app, @LaplacianMenuSelected, true);
            app.LaplacianMenu.Text = 'Laplacian';

            % Create SubstractionMenu
            app.SubstractionMenu = uimenu(app.KrawedziowanieMenu);
            app.SubstractionMenu.MenuSelectedFcn = createCallbackFcn(app, @SubstractionMenuSelected, true);
            app.SubstractionMenu.Text = 'Substraction';

            % Create KluczowanieMenu
            app.KluczowanieMenu = uimenu(app.UIFigure);
            app.KluczowanieMenu.Text = 'Kluczowanie';

            % Create ProbkowanieMenu
            app.ProbkowanieMenu = uimenu(app.KluczowanieMenu);
            app.ProbkowanieMenu.MenuSelectedFcn = createCallbackFcn(app, @ProbkowanieMenuSelected, true);
            app.ProbkowanieMenu.Text = 'Probkowanie';

            % Create PodmianaMenu
            app.PodmianaMenu = uimenu(app.KluczowanieMenu);
            app.PodmianaMenu.MenuSelectedFcn = createCallbackFcn(app, @PodmianaMenuSelected, true);
            app.PodmianaMenu.Text = 'Podmiana';

            % Create ProjektAIPOC134891_Kamil_BrzozowskiLabel
            app.ProjektAIPOC134891_Kamil_BrzozowskiLabel = uilabel(app.UIFigure);
            app.ProjektAIPOC134891_Kamil_BrzozowskiLabel.FontSize = 14;
            app.ProjektAIPOC134891_Kamil_BrzozowskiLabel.FontColor = [0.502 0.502 0.502];
            app.ProjektAIPOC134891_Kamil_BrzozowskiLabel.Position = [438 15 279 22];
            app.ProjektAIPOC134891_Kamil_BrzozowskiLabel.Text = 'Projekt AIPOC - 134891_Kamil_Brzozowski';

            % Create ParametrywczytanegoobrazuLabel
            app.ParametrywczytanegoobrazuLabel = uilabel(app.UIFigure);
            app.ParametrywczytanegoobrazuLabel.FontSize = 18;
            app.ParametrywczytanegoobrazuLabel.Position = [886 656 250 23];
            app.ParametrywczytanegoobrazuLabel.Text = 'Parametry wczytanego obrazu';

            % Create szerokoscLabel
            app.szerokoscLabel = uilabel(app.UIFigure);
            app.szerokoscLabel.Position = [886 622 250 22];
            app.szerokoscLabel.Text = 'szerokosc';

            % Create wysokoscLabel
            app.wysokoscLabel = uilabel(app.UIFigure);
            app.wysokoscLabel.Position = [886 593 250 22];
            app.wysokoscLabel.Text = 'wysokosc';

            % Create liczbaskladowychLabel
            app.liczbaskladowychLabel = uilabel(app.UIFigure);
            app.liczbaskladowychLabel.Position = [886 562 250 22];
            app.liczbaskladowychLabel.Text = 'liczba skladowych';

            % Create Button
            app.Button = uibutton(app.UIFigure, 'push');
            app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
            app.Button.BackgroundColor = [0.702 0.702 0.702];
            app.Button.FontSize = 18;
            app.Button.FontWeight = 'bold';
            app.Button.FontColor = [1 1 1];
            app.Button.Position = [142 87 30 30];
            app.Button.Text = '+';

            % Create Button_2
            app.Button_2 = uibutton(app.UIFigure, 'push');
            app.Button_2.ButtonPushedFcn = createCallbackFcn(app, @Button_2Pushed, true);
            app.Button_2.BackgroundColor = [0.702 0.702 0.702];
            app.Button_2.FontSize = 18;
            app.Button_2.FontWeight = 'bold';
            app.Button_2.FontColor = [1 1 1];
            app.Button_2.Position = [185 87 30 30];
            app.Button_2.Text = '-';

            % Create SkalowanieLabel
            app.SkalowanieLabel = uilabel(app.UIFigure);
            app.SkalowanieLabel.Position = [20 87 68 30];
            app.SkalowanieLabel.Text = 'Skalowanie';

            % Create RGBLabel
            app.RGBLabel = uilabel(app.UIFigure);
            app.RGBLabel.FontSize = 18;
            app.RGBLabel.Position = [886 514 44 23];
            app.RGBLabel.Text = 'RGB';

            % Create PoczatkowewartosciskladowychRGBLabel
            app.PoczatkowewartosciskladowychRGBLabel = uilabel(app.UIFigure);
            app.PoczatkowewartosciskladowychRGBLabel.Position = [886 477 250 22];
            app.PoczatkowewartosciskladowychRGBLabel.Text = 'Poczatkowe wartosci skladowych RGB:';

            % Create RLabel
            app.RLabel = uilabel(app.UIFigure);
            app.RLabel.Position = [886 447 250 22];
            app.RLabel.Text = 'R: ';

            % Create GLabel
            app.GLabel = uilabel(app.UIFigure);
            app.GLabel.Position = [886 416 250 22];
            app.GLabel.Text = 'G: ';

            % Create BLabel
            app.BLabel = uilabel(app.UIFigure);
            app.BLabel.Position = [886 385 250 22];
            app.BLabel.Text = 'B: ';

            % Create ProgowanieSliderLabel
            app.ProgowanieSliderLabel = uilabel(app.UIFigure);
            app.ProgowanieSliderLabel.Position = [20 254 68 22];
            app.ProgowanieSliderLabel.Text = 'Progowanie';

            % Create ProgowanieSlider
            app.ProgowanieSlider = uislider(app.UIFigure);
            app.ProgowanieSlider.Limits = [0 256];
            app.ProgowanieSlider.ValueChangingFcn = createCallbackFcn(app, @ProgowanieSliderValueChanging, true);
            app.ProgowanieSlider.Position = [142 264 150 3];

            % Create RESETButton
            app.RESETButton = uibutton(app.UIFigure, 'push');
            app.RESETButton.ButtonPushedFcn = createCallbackFcn(app, @RESETButtonPushed, true);
            app.RESETButton.BackgroundColor = [0.702 0.702 0.702];
            app.RESETButton.FontSize = 10;
            app.RESETButton.FontWeight = 'bold';
            app.RESETButton.FontColor = [1 1 1];
            app.RESETButton.Position = [142 135 73 30];
            app.RESETButton.Text = 'RESET';

            % Create UsuwaniefiltrowLabel
            app.UsuwaniefiltrowLabel = uilabel(app.UIFigure);
            app.UsuwaniefiltrowLabel.Position = [20 142 92 22];
            app.UsuwaniefiltrowLabel.Text = 'Usuwanie filtrow';

            % Create OperacjepodstawoweLabel
            app.OperacjepodstawoweLabel = uilabel(app.UIFigure);
            app.OperacjepodstawoweLabel.FontSize = 18;
            app.OperacjepodstawoweLabel.Position = [20 294 250 23];
            app.OperacjepodstawoweLabel.Text = 'Operacje podstawowe';

            % Create JasnoscSliderLabel
            app.JasnoscSliderLabel = uilabel(app.UIFigure);
            app.JasnoscSliderLabel.Position = [20 205 78 22];
            app.JasnoscSliderLabel.Text = 'Jasnosc';

            % Create JasnoscSlider
            app.JasnoscSlider = uislider(app.UIFigure);
            app.JasnoscSlider.Limits = [0 2];
            app.JasnoscSlider.ValueChangingFcn = createCallbackFcn(app, @JasnoscSliderValueChanging, true);
            app.JasnoscSlider.Position = [142 215 156 3];
            app.JasnoscSlider.Value = 1;

            % Create RSliderLabel
            app.RSliderLabel = uilabel(app.UIFigure);
            app.RSliderLabel.HorizontalAlignment = 'center';
            app.RSliderLabel.Position = [463 176 25 22];
            app.RSliderLabel.Text = 'R';

            % Create RSlider
            app.RSlider = uislider(app.UIFigure);
            app.RSlider.Limits = [0 2];
            app.RSlider.Orientation = 'vertical';
            app.RSlider.ValueChangingFcn = createCallbackFcn(app, @RSliderValueChanging, true);
            app.RSlider.Position = [496 187 3 82];
            app.RSlider.Value = 1;

            % Create BSliderLabel
            app.BSliderLabel = uilabel(app.UIFigure);
            app.BSliderLabel.HorizontalAlignment = 'center';
            app.BSliderLabel.Position = [664 176 25 22];
            app.BSliderLabel.Text = 'B';

            % Create BSlider
            app.BSlider = uislider(app.UIFigure);
            app.BSlider.Limits = [0 2];
            app.BSlider.Orientation = 'vertical';
            app.BSlider.ValueChangingFcn = createCallbackFcn(app, @BSliderValueChanging, true);
            app.BSlider.Position = [698 183 3 86];
            app.BSlider.Value = 1;

            % Create GSlider_2Label
            app.GSlider_2Label = uilabel(app.UIFigure);
            app.GSlider_2Label.HorizontalAlignment = 'center';
            app.GSlider_2Label.Position = [561 176 25 22];
            app.GSlider_2Label.Text = 'G';

            % Create GSlider_2
            app.GSlider_2 = uislider(app.UIFigure);
            app.GSlider_2.Limits = [0 2];
            app.GSlider_2.Orientation = 'vertical';
            app.GSlider_2.ValueChangingFcn = createCallbackFcn(app, @GSlider_2ValueChanging, true);
            app.GSlider_2.Position = [595 185 3 84];
            app.GSlider_2.Value = 1;

            % Create ModyfikacjaskadowychRGBLabel
            app.ModyfikacjaskadowychRGBLabel = uilabel(app.UIFigure);
            app.ModyfikacjaskadowychRGBLabel.FontSize = 18;
            app.ModyfikacjaskadowychRGBLabel.Position = [463 294 250 23];
            app.ModyfikacjaskadowychRGBLabel.Text = 'Modyfikacja składowych RGB';

            % Create GUILabel
            app.GUILabel = uilabel(app.UIFigure);
            app.GUILabel.FontSize = 18;
            app.GUILabel.Position = [473 127 250 23];
            app.GUILabel.Text = 'GUI';

            % Create DarkmodeSwitchLabel
            app.DarkmodeSwitchLabel = uilabel(app.UIFigure);
            app.DarkmodeSwitchLabel.HorizontalAlignment = 'center';
            app.DarkmodeSwitchLabel.Position = [473 91 64 22];
            app.DarkmodeSwitchLabel.Text = 'Dark mode';

            % Create DarkmodeSwitch
            app.DarkmodeSwitch = uiswitch(app.UIFigure, 'slider');
            app.DarkmodeSwitch.ValueChangedFcn = createCallbackFcn(app, @DarkmodeSwitchValueChanged, true);
            app.DarkmodeSwitch.Position = [574 92 45 20];

            % Create UIAxes
            app.UIAxes = uiaxes(app.UIFigure);
            title(app.UIAxes, 'Oryginal')
            app.UIAxes.Colormap = [];
            app.UIAxes.XColor = [0.902 0.902 0.902];
            app.UIAxes.XTick = [];
            app.UIAxes.YColor = [0.902 0.902 0.902];
            app.UIAxes.YTick = [];
            app.UIAxes.ZColor = [0.902 0.902 0.902];
            app.UIAxes.Color = [0.9882 0.9882 0.9882];
            app.UIAxes.FontSize = 10;
            app.UIAxes.MinorGridColor = [0.9412 0.9412 0.9412];
            app.UIAxes.Box = 'on';
            app.UIAxes.Position = [1 334 436 360];

            % Create UIAxes2
            app.UIAxes2 = uiaxes(app.UIFigure);
            title(app.UIAxes2, 'Kopia')
            app.UIAxes2.Colormap = [];
            app.UIAxes2.XColor = [0.902 0.902 0.902];
            app.UIAxes2.XTick = [];
            app.UIAxes2.YColor = [0.902 0.902 0.902];
            app.UIAxes2.YTick = [];
            app.UIAxes2.ZColor = [0.902 0.902 0.902];
            app.UIAxes2.LineWidth = 0.1;
            app.UIAxes2.Color = [0.9882 0.9882 0.9882];
            app.UIAxes2.FontSize = 10;
            app.UIAxes2.GridColor = [0.9412 0.9412 0.9412];
            app.UIAxes2.Box = 'on';
            app.UIAxes2.Position = [436 334 436 360];

            % 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 = projekt_kb

            % 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