forked from KyleZhang1118/Voice-Separation-and-Enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bss_mcrit.m
41 lines (37 loc) · 1.5 KB
/
bss_mcrit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [SDR,ISR,SIR,SAR]=bss_mcrit(s_true,e_spat,e_interf,e_artif)
% BSS_MCRIT Computation of some separation performance criteria given the
% decomposition of an estimated source image into four components
% representing respectively the true source image, spatial (or filtering)
% distortion, interference and artifacts.
%
% [SDR,ISR,SIR,SAR]=bss_mcrit(s_true,e_spat,e_interf,e_artif)
%
% Inputs:
% s_true: I x T matrix containing the true source image (one row per channel)
% e_spat: I x T matrix containing the spatial (or filtering) distortion component
% e_interf: I x T matrix containing the interference component
% e_artif: I x T matrix containing the artifacts component
%
% Outputs:
% SDR: Signal to Distortion Ratio
% ISR: source Image to Spatial distortion Ratio
% SIR: Source to Interference Ratio
% SAR: Sources to Artifacts Ratio
%%% Errors %%%
if nargin<4, error('Not enough input arguments.'); end
[It,Tt]=size(s_true);
[Is,Ts]=size(e_spat);
[Ii,Ti]=size(e_interf);
[Ia,Ta]=size(e_artif);
if ~((It==Is)&&(It==Ii)&&(It==Ia)), error('All the components must have the same number of channels.'); end
if ~((Tt==Ts)&&(Tt==Ti)&&(Tt==Ta)), error('All the components must have the same duration.'); end
%%% Energy ratios %%%
% SDR
SDR=10*log10(sum(sum(s_true.^2))/sum(sum((e_spat+e_interf+e_artif).^2)));
% ISR
ISR=10*log10(sum(sum(s_true.^2))/sum(sum(e_spat.^2)));
% SIR
SIR=10*log10(sum(sum((s_true+e_spat).^2))/sum(sum(e_interf.^2)));
% SAR
SAR=10*log10(sum(sum((s_true+e_spat+e_interf).^2))/sum(sum(e_artif.^2)));
return;