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

deconvolve RGB and some trial and (mostly) error

parent 3259b711
clear all, close all
rgb = [75 0 130]; % `indigo'
OD = -log(rgb + 1) % `optical density'
nOD = OD/norm(OD) % normalised OD
% from Java
OD = -(255*log(rgb +1 )/255) / log(255)
% but...
jOD = OD/norm(OD)
% is the same...
I = repmat(0:255, 3 ,1)'; % `intensity'
% blunt intensity scaling
clr = repmat(rgb, size(I, 1), 1).*I*255/130
% scale OD and convert back?
sOD =
for I = 0:255
% figure(1)
% hold on
% plot([I I], [0 255], 'color', clr, 'linewidth', 1)
% scale OD & convert back?
sOD = nOD*I;
% Java:
% Math.exp(-((Rscaled + Gscaled + Bscaled) - 255.0) * log255 / 255.0);
CLR(I+1, 1:3) = 1-exp(sOD)
% figure(2)
% hold on
% plot([I I], [0 255], 'color', CLR, 'linewidth', 1)
end
\ No newline at end of file
% dye RGB matrix
dyes = [255 0 0; % RGB stain 1
0 255 0; % RGB stain 2
0 0 255]; % RGB stain 3
% dye OD matrix
p = [1 0 0; % RGB OD's stain 1
0 1 0; % RGB OD's stain 2
0 0 1]; % RGB OD's stain 3
p = -log(dyes+1)
% normalise
M = p;
for c = 1:size(p, 2)
M(:, c) = M(:, c)/norm(p(:, c));
end
M = M
imRGB = [200; 100; 0];
% imRGB = [75 0 130]';
imOD = -log(imRGB + 1)
% imOD = imOD/norm(imOD)
amounts = inv(M)*imOD
atoR = exp(-amounts'.*M(1, :))-1
atoG = exp(-amounts'.*M(2, :))-1
atoB = exp(-amounts'.*M(3, :))-1
%
% od = -log(dyes+1)
% OD = -(255*log(dyes +1 )/255) / log(255)
%
% odtoI = exp(-od)-1
% ODtoI = exp(-OD*5.5)-1
\ No newline at end of file
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