function [output_common] = automatic_detection_g(data,Ts)
% Tato funkce získá společné pozice prahovaných parametrů.
% vstup: data - vstupní data, Ts - vzorkovací perioda
% výstup: output_common - společné pozice prahovaných parametrů
        
%% Main
        %output = fit_biexp(data(:,:,:,:));
        %output = fit_gauss(data(:,:,:,:));
        %save('output','output');
        
        output = load('output_AC09_gauss');
        
        %output = load('output_AC09_biexp');
        %output = load('output_AC010_1_biexp');
        %output = load('output_AC012_biexp');
        %output = load('output_AC014_biexp');
        
        %output = load('output_AC05_biexp');
        %output = load('output_AC08_biexp');
        %output = load('output_AC010_biexp');
        
        output = output.output;
                
%% Gauss

% A0 is the height of exp 
% A1 is the center of exp 
% A2 is sigma (the width) 
% A3 is the constant term

% Thresholding A0
output(:,:,:,1) = output(:,:,:,1)*Ts;
output1 = output(:,:,:,1)<(30*Ts) & output(:,:,:,1)>(2*Ts);
output(:,:,:,1) = output1(:,:,:);

% Thresholding A1
output(:,:,:,2) = output(:,:,:,2)*Ts;
output2 = output(:,:,:,2)<(100*Ts) & output(:,:,:,2)>(35*Ts);
output(:,:,:,2) = output2(:,:,:);

% Thresholding A2
output(:,:,:,3) = output(:,:,:,3)*Ts;
output3 = output(:,:,:,3)<(50*Ts) & output(:,:,:,3)>(10*Ts);
output(:,:,:,3) = output3(:,:,:);

% Thresholding 4
output4 = sum(data,4)/size(data,4);
temp4=(output4(:));
temp4 = temp4(temp4>0);
temp4 = mean(temp4);
output4(output4(:,:,:)<0.3*temp4)= 0;

%% Gauss
% rgbImage1 = cat(3, output(:,:,8,1), output(:,:,8,2), output(:,:,8,3));
% rgbImage1 = imrotate(rgbImage1 ,90);
% imshow(rgbImage1);

temp=cat(4,output1,output2,output3,output4);
temp(temp>0)=1;
temp(temp<0)=0;
output_common = sum(double(temp),4)>=4;

end