diff --git a/matlab/+SSF/getClipLimits.m b/matlab/+SSF/getClipLimits.m index 423e83296bbdca01b9575d4777b874e278f748a7..dc177d9e883cf69810d583fda0942c05e73d2faf 100644 --- a/matlab/+SSF/getClipLimits.m +++ b/matlab/+SSF/getClipLimits.m @@ -13,6 +13,7 @@ if ~exist('tClip','var') end p = ljsStartParallel(); kymoPixels = {}; +clipLimits = {}; parfor ff=1:length(flist) kp = {}; for c = 1:length(targetChannelNumbers) @@ -25,22 +26,27 @@ parfor ff=1:length(flist) im_ff(im_ff>0)=0; im_ff = abs(im_ff); end - kp{c} = im_ff(find(im_ff)); - kymoPixels{ff} = kp; - end -end -kymoPixels = vertcat(kymoPixels{:}); + px = im_ff(find(im_ff)); + kymoPixels{ff} = px; -clipLimits = []; -for c = 1:size(kymoPixels,2) - % anything other than [0,1] gets set to the corresponding percentile - idx = find(clipRange); - if ~isempty(idx) - px = kymoPixels{:,c}; - clipLimits(c,idx) = [prctile(px,clipRange(idx))]; - end - clipLimits(c,find(clipRange==0)) = 0; -end +% clipLimits{ff} = [mean(px)-std(px),mean(px)+std(px)]; %prctile(kp{c},[0.5,99.5]); + clipLimits{ff} = prctile(px,100.*[1/255:1/255:1-1/255]); + end +end +% kymoPixels = vertcat(kymoPixels{:}); +% clipLimits = prctile(kymoPixels,100.*[1/255:1/255:1-1/255]); -4; \ No newline at end of file +% clipLimits = []; +% for c = 1:size(kymoPixels,2) +% % anything other than [0,1] gets set to the corresponding percentile +% idx = find(clipRange); +% if ~isempty(idx) +% px = kymoPixels{:,c}; +% clipLimits(c,idx) = [mean(px)-std(px),mean(px)+std(px)]; %[prctile(px,clipRange(idx))]; +% end +% clipLimits(c,find(clipRange==0)) = 0; +% end +% +% +% 4; \ No newline at end of file diff --git a/matlab/+SSF/quantize8.m b/matlab/+SSF/quantize8.m index 7feb548d843a193fc24fa603764b0eb716a08b55..1dbd08aae04dce4c1cd80852fee2cc602c4bd804 100644 --- a/matlab/+SSF/quantize8.m +++ b/matlab/+SSF/quantize8.m @@ -5,11 +5,15 @@ im = im_in; if isa(im,'uint8') return end -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)); -end -im = im2uint8(im); + +im = uint8(imquantize(im,clipLimits)); +% +% 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)); +% end +% im = im2uint8(im); + im = max(im,1); im(0 == im_in) = 0; \ No newline at end of file