Skip to content
Snippets Groups Projects
Commit dba2a893 authored by ac_fx's avatar ac_fx
Browse files

quantize8 background

parent c3ef1727
No related branches found
No related tags found
No related merge requests found
% clipLimits = [minVal,maxVal]; % clipLimits = [minVal,maxVal];
function [im, clipLimits] = quantize8(im,clipLimits) function [im, clipLimits] = quantize8(im_in,clipLimits)
if isa(im,'uint8') if isa(im,'uint8')
return return
end end
for c = 1:size(im,4) for c = 1:size(im,4)
im(:,:,:,c) = max(im(:,:,:,c),clipLimits(c,1)); im(:,:,:,c) = max(im_in(:,:,:,c),clipLimits(c,1));
im(:,:,:,c) = min(im(:,:,:,c),clipLimits(c,2)); im(:,:,:,c) = min(im_in(:,:,:,c),clipLimits(c,2));
im(:,:,:,c) = (im_in(:,:,:,c) - clipLimits(c,1)) ./ (clipLimits(c,2) - clipLimits(c,1));
im(:,:,:,c) = (im(:,:,:,c) - clipLimits(c,1)) ./ (clipLimits(c,2) - clipLimits(c,1));
im(:,:,:,c) = im2uint8(im(:,:,:,c));
im(:,:,:,c) = max(im(:,:,:,c),1); % exclude 0 -- only for background
im(1,1,1,c) = 0; % must have at least one background...
end end
im = im2uint8(im); im = im2uint8(im);
im(0 == im_in) = 0;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment