function varargout = main(varargin)
% MAIN MATLAB code for main.fig
%      MAIN, by itself, creates a new MAIN or raises the existing
%      singleton*.
%
%      H = MAIN returns the handle to a new MAIN or the handle to
%      the existing singleton*.
%
%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN.M with the given input arguments.
%
%      MAIN('Property','Value',...) creates a new MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to main_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help main

% Last Modified by GUIDE v2.5 29-May-2015 07:43:35

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_OpeningFcn, ...
                   'gui_OutputFcn',  @main_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before main is made visible.
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to main (see VARARGIN)

% Choose default command line output for main
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

global conpic;
global obr;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
FDD = str2double(get(handles.edit1,'String'));
FID = str2double(get(handles.edit2,'String'));
D = str2double(get(handles.edit3,'String'));
F = str2double(get(handles.edit4,'String'));
DID=FDD-FID;
DIR = (FID/FDD)*D;
FIR = (DID/FDD)*F;
set(handles.slider2,'Value',DID/FDD);
T=str2double(get(handles.edit5,'String'));
t=str2double(get(handles.edit6,'String'));
t=T/t;
Ep=2*pi*(t/T);
FWHM=sqrt((FIR*FIR)+(DIR*DIR)+(Ep*Ep));
set(handles.edit8,'String',FWHM);
x=linspace(0,D,1000);
y=linspace(0,FDD,1000);
Dx=[0 D];
Dy=[0 0];
Fx=[0 D];
Fy=[FDD FDD];
DIx=[0 0];
DIy=[0 DID];
FIx=[0 0];
FIy=[DID FDD];

axes(handles.axes1);
plot(DIx,DIy,'y','LineWidth',5)
hold on;
plot(FIx,FIy,'g','LineWidth',5)
plot(x,DID,'r')
plot(Dx,Dy,'k','LineWidth',5)
plot(Fx,Fy,'k','LineWidth',5)
plot(x,y)
legend('Vzdálenost detektor-izocentrum','Vzdálenost ohnisko-izocentrum','Izocentrum rotace','Location','northwestoutside')


hold off;
set(gca,'xtick',[],'ytick',[])
axis normal tight
set(handles.text7,'Visible','on');
set(handles.text8,'Visible','on');


%%%%%%vysledky
% figure(216)
% plot(DIx,DIy,'y','LineWidth',5)
% hold on;
% plot(FIx,FIy,'g','LineWidth',5)
% plot([x(1) x(end)],[DID DID],'r','LineWidth',5)
% plot(Dx,Dy,'k','LineWidth',5)
% plot(Fx,Fy,'k','LineWidth',5)
% plot(x,y)
% legend('Vzdálenost detektor-izocentrum','Vzdálenost ohnisko-izocentrum','Izocentrum rotace','Location','northwestoutside')
% hold off;
% set(gca,'xtick',[],'ytick',[])
% axis normal tight


%%%%%%%konec




[x y ff1 ff2 f3]=vyp_PSF(FWHM,D,F);

axes(handles.axes2);
plot(x(ff1:ff2),f3,'r');
hold on
plot(x,y);
legend('FWHM')
xlabel('Šířka [mm]')
ylabel('PSF')
hold off;


%subplot na vysledky
% figure(20)
% subplot(1,2,1)
% plot(x(ff1:ff2),f3,'r');
% hold on
% plot(x,y);
% legend('FWHM')
% xlabel('Šířka [mm]')
% ylabel('PSF')
% hold off;


[Mx MTF] = vyp_MTF(y,FWHM);

axes(handles.axes5)
plot(Mx,MTF)
xlim([0 max(Mx)])
ylabel('MTF')
xlabel('Prostorová frekvence [lp/mm]')

xx=-1:0.1:1;
yy=-1:0.1:1;
A=1;
x0=0;
y0=0;
c=(FWHM)/(2*sqrt(2*log(2)));
for x=1:21
    for y=1:21
out(x,y)=A*exp(-((((xx(x)-x0).^2)/(2*c^2))+(((yy(y)-y0).^2)/(2*c^2))));
    end
end
global obr;
if (isempty(obr))
obr=imread('obraz.jpeg');
end
ss=size(obr);
if (length(ss)>=3)
    obr=rgb2gray(obr);
end
pyc=conv2(double(obr),out,'same');
mm=max(max(pyc));
pyc=pyc./mm;
pyc=pyc.*255;
pyc=uint8(pyc);
axes(handles.axes3)
imshow(obr)
axes(handles.axes4)
imshow(pyc)
global conpic
conpic=pyc;
global gMTF
gMTF=MTF;
global gFWHM
gFWHM=FWHM;
set(handles.edit11,'String','')





function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
FDD = str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
D = str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
F = str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
iso = get(hObject,'Value');
FDD = str2double(get(handles.edit1,'String'));
D = str2double(get(handles.edit3,'String'));
F = str2double(get(handles.edit4,'String'));

set(handles.edit2,'String',FDD-(FDD*iso));
FID=FDD-(FDD*iso);
DID=FDD-FID;
DIR = (FID/FDD)*D;
FIR = (DID/FDD)*F;
T=str2double(get(handles.edit5,'String'));
t=str2double(get(handles.edit6,'String'));
t=T/t;
Ep=2*pi*(t/T);
FWHM=sqrt((FIR*FIR)+(DIR*DIR)+(Ep*Ep));
set(handles.edit8,'String',FWHM);
lim=1;
if D>lim
    lim=D;
elseif F>lim
    lim=F;
end
x=linspace(0,D,1000);
y=linspace(0,FDD,1000);
Dx=[0 D];
Dy=[0 0];
Fx=[0 D];
Fy=[FDD FDD];
DIx=[0 0];
DIy=[0 DID];
FIx=[0 0];
FIy=[DID FDD];
axes(handles.axes1);


plot(DIx,DIy,'y','LineWidth',5)
hold on;
plot(FIx,FIy,'g','LineWidth',5)
 plot(x,FDD*iso,'r')
% plot(x,DID,'r')
plot(Dx,Dy,'k','LineWidth',5)
plot(Fx,Fy,'k','LineWidth',5)
plot(x,y)
legend('Vzdálenost detektor-izocentrum','Vzdálenost ohnisko-izocentrum','Izocentrum rotace','Location','northwestoutside')


hold off;
set(gca,'xtick',[],'ytick',[])
axis normal tight
set(handles.text7,'Visible','on');
set(handles.text8,'Visible','on');
axes(handles.axes2);
c=FWHM/(2*sqrt(2*log(2)));
x=-lim:0.001:lim;
y=gaussmf(x,[c 0]);


uy=abs(y-0.5);
[f1 ff1]=min(uy(1:1000*lim));
[f2 ff2]=min(uy(lim*1001:end));
ff2=ff2+1001*lim;
f3(1:abs(ff2-ff1)+1)=0.5;
plot(x(ff1:ff2),f3,'r');
hold on
plot(x,y);
legend('FWHM')
ylabel('PSF')
hold off;

pMTF=abs(fft(y,100000));
for i=1:500
     if pMTF(i)<=0.1
         break;
     end
     MTF(i)=pMTF(i);
end
MTF=MTF/max(MTF);
Mx=linspace(0,1/FWHM,length(MTF));
axes(handles.axes5)
plot(Mx,MTF)
xlim([0 max(Mx)])
ylabel('MTF')
xlabel('Prostorová frekvence [lp/mm]')

xx=-1:0.075:1;
yy=-1:0.075:1;
A=1;
x0=0;
y0=0;
for x=1:27
    for y=1:27
out(x,y)=A*exp(-((((xx(x)-x0).^2)/(2*c^2))+(((yy(y)-y0).^2)/(2*c^2))));
    end
end
global obr
ss=size(obr);
if (length(ss)>=3)
    obr=rgb2gray(obr);
end
pyc=conv2(double(obr),out,'same');
mm=max(max(pyc));
pyc=pyc./mm;
pyc=pyc.*255;
pyc=uint8(pyc);
axes(handles.axes3)
imshow(obr)
axes(handles.axes4)
imshow(pyc)
global conpic
conpic = pyc;
global gMTF
gMTF=MTF;
global gFWHM
gFWHM=FWHM;
set(handles.edit11,'String','')

% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double

% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
run vliv_krok
close untitled




% --- Executes when selected object is changed in uipanel1.
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel1 
% 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)
a(1)=get(handles.radio1,'Value');
a(2)=get(handles.radio2,'Value');
a(3)=get(handles.radio3,'Value');

if a(1)==1
     set(handles.edit3,'Enable','on');
    set(handles.edit4,'Enable','on');
    set(handles.edit5,'Enable','on');
    set(handles.edit6,'Enable','on');
    set(handles.edit2,'Enable','on');
    set(handles.edit1,'Enable','on');
    set(handles.slider2,'Enable','on');
    set(handles.pushbutton4,'Enable','on');
    set(handles.pushbutton5,'Enable','on');
    set(handles.pushbutton6,'Enable','on');
    set(handles.pushbutton10,'Enable','on');
    set(handles.pushbutton11,'Enable','on');
    set(handles.pushbutton12,'Enable','on');
    set(handles.pushbutton13,'Enable','on');
    set(handles.pushbutton9,'Enable','on');
    set(handles.pushbutton8,'Enable','on');
    set(handles.pushbutton7,'Enable','on');
    set(handles.pushbutton14,'Enable','on');
    set(handles.pushbutton15,'Enable','on');
elseif a(2)==1
    set(handles.edit3,'Enable','off');
    set(handles.edit4,'Enable','off');
    set(handles.edit5,'Enable','off');
    set(handles.edit6,'Enable','off');
    set(handles.edit2,'Enable','on');
    set(handles.edit1,'Enable','on');
    set(handles.slider2,'Enable','on');
    set(handles.pushbutton4,'Enable','off');
    set(handles.pushbutton5,'Enable','off');
    set(handles.pushbutton6,'Enable','off');
    set(handles.pushbutton10,'Enable','off');
    set(handles.pushbutton11,'Enable','off');
    set(handles.pushbutton12,'Enable','off');
    set(handles.pushbutton13,'Enable','off');
    set(handles.pushbutton9,'Enable','off');
    set(handles.pushbutton8,'Enable','on');
    set(handles.pushbutton7,'Enable','on');
    set(handles.pushbutton14,'Enable','on');
    set(handles.pushbutton15,'Enable','on');
elseif a(3)==1
    set(handles.edit3,'Enable','on');
    set(handles.edit4,'Enable','on');
    set(handles.edit5,'Enable','on');
    set(handles.edit6,'Enable','on');
    set(handles.edit2,'Enable','off');
    set(handles.edit1,'Enable','off');
    set(handles.slider2,'Enable','off');
     set(handles.pushbutton4,'Enable','on');
    set(handles.pushbutton5,'Enable','on');
    set(handles.pushbutton6,'Enable','on');
    set(handles.pushbutton10,'Enable','on');
    set(handles.pushbutton11,'Enable','on');
    set(handles.pushbutton12,'Enable','on');
    set(handles.pushbutton13,'Enable','on');
    set(handles.pushbutton9,'Enable','on');
    set(handles.pushbutton8,'Enable','off');
    set(handles.pushbutton7,'Enable','off');
    set(handles.pushbutton14,'Enable','off');
    set(handles.pushbutton15,'Enable','off');
end

    


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
DID = 950-540;
set(handles.edit1,'String','950');
set(handles.edit2,'String','540');
set(handles.edit3,'String','0.5');
set(handles.edit4,'String','0.8');
set(handles.edit5,'String','0.5');
set(handles.edit6,'String','1000');
set(handles.slider2,'Value',DID/950);

iso=DID/950;
FDD = 950;
D=0.5;
x=linspace(0,D,1000);
y=linspace(0,FDD,1000);
Dx=[0 D];
Dy=[0 0];
Fx=[0 D];
Fy=[FDD FDD];
DIx=[0 0];
DIy=[0 DID];
FIx=[0 0];
FIy=[DID FDD];
axes(handles.axes1);
plot(x,y)
hold on;
plot(x,FDD*iso,'k')
hold off;
set(gca,'xtick',[],'ytick',[])
axis normal tight


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit3,'String'));
set(handles.edit3,'String',a+0.1);

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit3,'String'));
set(handles.edit3,'String',a-0.1);


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit4,'String'));
set(handles.edit4,'String',a+0.1);

% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit2,'String'));
set(handles.edit2,'String',a+10);

% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit1,'String'));
set(handles.edit1,'String',a+10);


% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit6,'String'));
set(handles.edit6,'String',a+10);


% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit5,'String'));
set(handles.edit5,'String',a+0.1);


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit4,'String'));
set(handles.edit4,'String',a-0.1);


% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit5,'String'));
set(handles.edit5,'String',a-0.1);


% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit6,'String'));
set(handles.edit6,'String',a-10);


% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit2,'String'));
set(handles.edit2,'String',a-10);

% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=str2double(get(handles.edit1,'String'));
set(handles.edit1,'String',a-10);


% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obr
global conpic
figure
subplot(1,2,1)
imshow(obr)
title('Původní obraz')
subplot(1,2,2)
imshow(conpic)
title('Obraz po konvoluci')


% --- Executes on button press in pushbutton18.
function pushbutton18_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obr
obr = [];
[FileName,PathName] = uigetfile({'*.jpeg';'*.jpg';'*.png';'*.bmp'},'Vyberte obraz');
y=[PathName FileName];

obr = imread(y);
if (isempty(obr))
    warndlg('Obraz nenačten')
end


% --- Executes on button press in pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global gMTF
global gFWHM
osx=linspace(0,1/gFWHM,length(gMTF));
figure
plot(osx,gMTF)
xlim([0 max(osx)])
xlabel('Prostorová frekvence [lp/mm]')
ylabel('MTF')



function edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double


% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double


% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton20.
function pushbutton20_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global gMTF
global gFWHM
hodMTF=str2num(get(handles.edit12,'String'));
temp=gMTF-hodMTF;
[h p]=min(abs(temp));
Mx=linspace(0,1/gFWHM,length(gMTF));
x=[Mx(p) Mx(p)];
y=[0 gMTF(p)];
xx=[0 Mx(p)];
yy=[gMTF(p) gMTF(p)];
axes(handles.axes5)
plot(Mx,gMTF)
xlim([0 max(Mx)])
xlabel('Prostorová frekvence [lp/mm]')
ylabel('MTF')
hold on
plot(x,y,'r')
plot(xx,yy,'r')
hold off
set(handles.edit11,'String',Mx(p))

% figure(20)
% subplot(1,2,2)
% plot(Mx,gMTF)
% xlim([0 max(Mx)])
% xlabel('Prostorová frekvence [lp/mm]')
% ylabel('MTF')
% hold on
% plot(x,y,'r')
% plot(xx,yy,'r')
% hold off
