Commit 65ad9d7d authored by Turnhout, M.C. van's avatar Turnhout, M.C. van
Browse files

support Octave compatility

parent 0b8b6876
......@@ -27,16 +27,27 @@ if size(K, 2) < 3, K(3, 3) = 0; end
if numel(pam) < 3, pam(3) = 0; end
% reconstruct RGB with all dyes, set negative values to zero with subplus
RGB = subplus( (Imax+1)*exp(-K*pam) - 1);
% reconstruct RGB with all dyes,
if exist ('OCTAVE_VERSION', 'builtin')
% Octave does not know subplus
RGB = (Imax+1)*exp(-K*pam) - 1;
RGB(RGB < 0) = 0;
else
% set negative values automagically to zero with subplus
RGB = subplus( (Imax+1)*exp(-K*pam) - 1);
end
if nargout > 1
% calculate individual dye RGBs
PQR = zeros(3);
for c = 1:3 % loop (backwards) over dyes
% RGB of this dye only in column c
PQR(:, c) = subplus( (Imax-1)*exp(-pam(c)*K(:, c)) - 1);
PQR(:, c) = (Imax-1)*exp(-pam(c)*K(:, c)) - 1;
end
% don't forget to remove negative values
PQR(PQR < 0) = 0;
end
% part of ClDlab: https://gitlab.tue.nl/STEM/ClDlab
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment