diff --git a/matlab/+SSF/quantize8.m b/matlab/+SSF/quantize8.m
index 1a2a0f119da3e86867c2433fc4da199bb0480fd6..b367f47535ea1f9194d82f92e9e86a40ab509836 100644
--- a/matlab/+SSF/quantize8.m
+++ b/matlab/+SSF/quantize8.m
@@ -4,11 +4,15 @@ function im = quantize8(im,clipLimits)
 if isa(im,'uint8')
     return
 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 = 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
+