Skip to content
Snippets Groups Projects
Commit cf00d171 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Added signal analysis basic functions

parent 862f9d19
No related branches found
No related tags found
No related merge requests found
...@@ -131,6 +131,7 @@ function initialise_gt(ignore_id19) ...@@ -131,6 +131,7 @@ function initialise_gt(ignore_id19)
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Imaging')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Imaging'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Indexter')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Indexter'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Maths')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Maths'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_NoiseAnalysis'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_OAR')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_OAR'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Parameters')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Parameters'));
addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Python')); addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Python'));
......
function a = gtEvalSignalAutocorrelation(s, t)
a = gtImgMeanValue(s .* circshift(s, t));
end
\ No newline at end of file
function n = gtGenerateAdditiveWhiteNoise(dims, total_energy, data_type)
if (~exist('data_type', 'var'))
data_type = 'single';
end
if (iscell(dims))
n = cell(dims);
summed_energy = 0;
for ii = 1:numel(n)
n{ii} = rand(dims, data_type);
summed_energy = summed_energy + gtGetSignalEnergy(n{ii});
end
for ii = 1:numel(n)
n{ii} = n{ii} * (total_energy / summed_energy);
end
else
n = rand(dims, data_type);
n = n * (total_energy / gtGetSignalEnergy(n));
end
end
function s = gtGetSignalAutocorrelation(s)
s = convn(s, s, 'same') / numel(s);
end
\ No newline at end of file
function e = gtGetSignalEnergy(s)
e = sum(sum(abs(s)));
e = sum(e(:)) / numel(s);
end
\ No newline at end of file
function r = gtGetSignalNoiseRatio(s, n, unit)
if (~exist('unit', 'var'))
unit = 'logaritmic';
end
r = gtGetSignalPower(s) / gtGetSignalPower(n);
switch(unit)
case 'decimal'
% Nothing
case 'logaritmic'
r = 10 * log10(r);
end
end
\ No newline at end of file
function p = gtGetSignalPower(s)
p = gtImgMeanValue(s .* s);
end
\ No newline at end of file
function s = gtGetSignalSpectralDensityPower(s)
s = gtGetSignalAutocorrelation(s);
s = fftn(ifftshift(s));
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment