Skip to content
Snippets Groups Projects
Commit 2ed10cda authored by ac's avatar ac
Browse files

SSF.quantize8 per channel

parent af28cef4
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,15 @@ function im = quantize8(im,clipLimits) ...@@ -4,11 +4,15 @@ function im = quantize8(im,clipLimits)
if isa(im,'uint8') if isa(im,'uint8')
return return
end end
im = max(im,clipLimits(1));
im = min(im,clipLimits(2));
im = (im - clipLimits(1)) ./ (clipLimits(2) - clipLimits(1)); for c = 1:size(im,4)
im(:,:,:,c) = max(im(:,:,:,c),clipLimits(c,1));
im(:,:,:,c) = min(im(:,:,:,c),clipLimits(c,2));
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
im = im2uint8(im); im = im2uint8(im);
im = max(im,1); % exclude 0 -- only for background
im(1,1) = 0; % make sure at least 1 pixel hits background
\ 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