diff --git a/convert.m b/convert.m index 9d8f055da202eab48e0f8847426fb09cbdedde3e..d36a6a8d9f5446b934ce6e5236bb15bcc295b765 100644 --- a/convert.m +++ b/convert.m @@ -2,22 +2,25 @@ function frames = convert(frames,varargin) %CONVERT Summary of this function goes here % Detailed explanation goes here +[~,defBitDepth] = utils.precision(class(frames{1})); p = inputParser; p.StructExpand = true; p.KeepUnmatched = true; p.addOptional('outColSpace' , 'ycbcr' , @ischar); p.addOptional( 'inColSpace' , 'rgb' , @ischar); +p.addOptional( 'bitDepth' , defBitDepth , @isnumeric); p.parse(varargin{:}); inColSpace = p.Results.inColSpace; outColSpace = p.Results.outColSpace; +bitDepth = p.Results.bitDepth; imgSize = ndims(frames{1}); switch imgSize case 3 if (strcmp(inColSpace,'rgb') && strcmp(outColSpace,'ycbcr')) - frames = cellfun(@utils.rgb2ycbcr,frames,'UniformOutput',false); + frames = cellfun(@(f) utils.rgb2ycbcr(f,bitDepth),frames,'UniformOutput',false); elseif (strcmp(inColSpace,'ycbcr') && strcmp(outColSpace,'rgb')) - frames = cellfun(@utils.ycbcr2rgb,frames,'UniformOutput',false); + frames = cellfun(@(f) utils.ycbcr2rgb(f,bitDepth),frames,'UniformOutput',false); end case 2 warning('Monochrome image, no conversion');