Skip to content
Snippets Groups Projects
Commit 64abcc06 authored by Eric Wait's avatar Eric Wait
Browse files

Auto transfer function will deal with blank or bright images

parent f79b1e18
No related branches found
No related tags found
No related merge requests found
......@@ -5,15 +5,30 @@ function AutoTransferFunction(im)
for c=1:size(im,4)
curIm = imC(:,:,:,c,:);
if (nnz(curIm(:))==0)
lb(c) = 0;
ub(c) = 255;
continue
end
N = histcounts(curIm(curIm>0),255);
forwardSum = cumsum(N);
lowerBound = forwardSum > sum(N)*0.05;
lb(c) = find(lowerBound,1,'first');
l = find(lowerBound,1,'first');
if (isempty(l))
lb(c) = 0;
else
lb(c) = l;
end
reverseSum = cumsum(N,'reverse');
upperBound = reverseSum < sum(N)*0.005;
ub(c) = find(upperBound,1,'first');
u = find(upperBound,1,'first');
if (isempty(u))
ub(c) = 255;
else
ub(c) = u;
end
end
[imageData, ucolors, channelData] = D3d.UI.Ctrl.GetUserData();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment