-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputeAveSandFractionOfOPCARealizations.m
26 lines (26 loc) · 1.27 KB
/
computeAveSandFractionOfOPCARealizations.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
function [OPCASandFracAve, OPCAThresSandFracAve] = computeAveSandFractionOfOPCARealizations(OPCARealizMat, Nc)
% Authors: H. X. Vo and L. J. Durlorfky
% Note: this function is not written for efficiency but rather than for easy to understand
%% Computing sand-fraction using pixels with values "0" and "1" only
OPCAShaleFracAve = 0;
OPCASandFracAve = 0;
NrOPCA = size(OPCARealizMat, 2);
for realizCounter=1:NrOPCA %loop through each realization
xr = OPCARealizMat(:, realizCounter);
shaleFrac = sum(xr == 0) / (sum(xr == 0) + sum(xr == 1));
OPCAShaleFracAve = OPCAShaleFracAve + shaleFrac / NrOPCA; % computing average
sandFrac = sum(xr == 1) / (sum(xr == 0) + sum(xr == 1));
OPCASandFracAve = OPCASandFracAve + sandFrac / NrOPCA; % computing average
end
%% Computing sand-fraction using threshold for pixel values
OPCAThresShaleFracAve = 0;
OPCAThresSandFracAve = 0;
for realizCounter=1:NrOPCA %loop through each realization
xr = OPCARealizMat(:, realizCounter);
level = 0.5;
shaleFrac = sum(xr < level) / Nc;
OPCAThresShaleFracAve = OPCAThresShaleFracAve + shaleFrac / NrOPCA; % computing average
sandFrac = sum(xr >= level) / Nc;
OPCAThresSandFracAve = OPCAThresSandFracAve + sandFrac / NrOPCA; % computing average
end
end