gusucode.com > visionhdl工具箱matlab源码程序 > visionhdl/visionhdl/+visionhdl/en/ChromaResampler.m

    classdef ChromaResampler< matlab.System & matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & matlab.system.mixin.Nondirect
%ChromaResampler Downsample or upsample chroma components of a YCbCr signal.
%  chromaResamp = visionhdl.ChromaResampler returns a chroma resampling 
%  System object, chromaResamp, that down/up samples chroma components of a 
%  YCbCr signal to reduce the bandwidth and/or storage requirements.
%
%  chromaResamp = visionhdl.ChromaResampler('PropertyName',PropertyValue,...)
%  returns a chroma resampling System object, chromaResamp, with each
%  specified property set to the specified value.
%
%  Step method syntax:
%  [pixOut,ctrlOut] = step(chromaResamp,pixIn,ctrlIn) resamples the input 
%  chrominance components. pixIn and pixOut are vectors of three elements, 
%  namely, Y, Cb, and Cr. ctrlIn and ctrlOut are structures consisting of 
%  five control signals. See also <a href="matlab:doc visionhdl.FrameToPixels">visionhdl.FrameToPixels</a> or 
%  <a href="matlab:doc pixelcontrolstruct">pixelcontrolstruct</a>.
% 
%  System objects may be called directly like a function instead of using
%  the step method. For example, y = step(obj, x) and y = obj(x) are
%  equivalent.
%
%  ChromaResampler methods:
%
%   step     - See above description for use of this method
%   release  - Allow property value and input characteristics changes
%   clone    - Create chroma resampler object with same property values
%   isLocked - Locked status (logical)
%
%  ChromaResampler properties:
%
%   Resampling - Resampling format 
%   AntialiasingFilterSource - The source of the antialiasing filter
%   HorizontalFilterCoefficients - Filter used to prevent aliasing when downsampling the chroma components
%   InterpolationFilter - Interpolation method used to approximate the missing chrominance values  when upsampling the chroma components
%   RoundingMethod - Rounding method when a number cannot be represented exactly
%   OverflowAction - wrap or saturate in the case of overflow
%   CustomCoefficientsDataType - customized coefficients data type
%
%   % EXAMPLE:
%   % Apply Chroma resampler to downsample an image
% frm2pix = visionhdl.FrameToPixels(...
%     'NumComponents',3,...
%     'VideoFormat','custom',...
%     'ActivePixelsPerLine',66,...
%     'ActiveVideoLines',44,...
%     'TotalPixelsPerLine',116,...
%     'TotalVideoLines',54,...
%     'StartingActiveLine',6,...
%     'FrontPorch',25);
% [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);       
% 
% pix2frm = visionhdl.PixelsToFrame(...
%     'NumComponents',3,...
%     'VideoFormat','custom',...
%     'ActivePixelsPerLine',actPixPerLine,...
%     'ActiveVideoLines',actLine);
% 
% downSamp = visionhdl.ChromaResampler;
%   
% frmFull = imread('pears.png');
% frmIn = imresize(frmFull,[actLine actPixPerLine]);
% imshow(frmIn);
%
% pixOutVec = zeros(numPixPerFrm,3,'uint8');
% ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
%
% [pixInVec,ctrlInVec] = step(frm2pix,rgb2ycbcr(frmIn));
% for p = 1:numPixPerFrm    
%     [pixOutVec(p,:),ctrlOutVec(p)] = step(downSamp,pixInVec(p,:),ctrlInVec(p));
% end
% [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
%     
% if frmValid
%    figure;
%    imshow(ycbcr2rgb(frmOut));
% end
%
%   See also vision.ChromaResampler.

 
%   Copyright 2014-2016 The MathWorks, Inc.

    methods
        function out=ChromaResampler
            %ChromaResampler Downsample or upsample chroma components of a YCbCr signal.
            %  chromaResamp = visionhdl.ChromaResampler returns a chroma resampling 
            %  System object, chromaResamp, that down/up samples chroma components of a 
            %  YCbCr signal to reduce the bandwidth and/or storage requirements.
            %
            %  chromaResamp = visionhdl.ChromaResampler('PropertyName',PropertyValue,...)
            %  returns a chroma resampling System object, chromaResamp, with each
            %  specified property set to the specified value.
            %
            %  Step method syntax:
            %  [pixOut,ctrlOut] = step(chromaResamp,pixIn,ctrlIn) resamples the input 
            %  chrominance components. pixIn and pixOut are vectors of three elements, 
            %  namely, Y, Cb, and Cr. ctrlIn and ctrlOut are structures consisting of 
            %  five control signals. See also <a href="matlab:doc visionhdl.FrameToPixels">visionhdl.FrameToPixels</a> or 
            %  <a href="matlab:doc pixelcontrolstruct">pixelcontrolstruct</a>.
            % 
            %  System objects may be called directly like a function instead of using
            %  the step method. For example, y = step(obj, x) and y = obj(x) are
            %  equivalent.
            %
            %  ChromaResampler methods:
            %
            %   step     - See above description for use of this method
            %   release  - Allow property value and input characteristics changes
            %   clone    - Create chroma resampler object with same property values
            %   isLocked - Locked status (logical)
            %
            %  ChromaResampler properties:
            %
            %   Resampling - Resampling format 
            %   AntialiasingFilterSource - The source of the antialiasing filter
            %   HorizontalFilterCoefficients - Filter used to prevent aliasing when downsampling the chroma components
            %   InterpolationFilter - Interpolation method used to approximate the missing chrominance values  when upsampling the chroma components
            %   RoundingMethod - Rounding method when a number cannot be represented exactly
            %   OverflowAction - wrap or saturate in the case of overflow
            %   CustomCoefficientsDataType - customized coefficients data type
            %
            %   % EXAMPLE:
            %   % Apply Chroma resampler to downsample an image
            % frm2pix = visionhdl.FrameToPixels(...
            %     'NumComponents',3,...
            %     'VideoFormat','custom',...
            %     'ActivePixelsPerLine',66,...
            %     'ActiveVideoLines',44,...
            %     'TotalPixelsPerLine',116,...
            %     'TotalVideoLines',54,...
            %     'StartingActiveLine',6,...
            %     'FrontPorch',25);
            % [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);       
            % 
            % pix2frm = visionhdl.PixelsToFrame(...
            %     'NumComponents',3,...
            %     'VideoFormat','custom',...
            %     'ActivePixelsPerLine',actPixPerLine,...
            %     'ActiveVideoLines',actLine);
            % 
            % downSamp = visionhdl.ChromaResampler;
            %   
            % frmFull = imread('pears.png');
            % frmIn = imresize(frmFull,[actLine actPixPerLine]);
            % imshow(frmIn);
            %
            % pixOutVec = zeros(numPixPerFrm,3,'uint8');
            % ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
            %
            % [pixInVec,ctrlInVec] = step(frm2pix,rgb2ycbcr(frmIn));
            % for p = 1:numPixPerFrm    
            %     [pixOutVec(p,:),ctrlOutVec(p)] = step(downSamp,pixInVec(p,:),ctrlInVec(p));
            % end
            % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
            %     
            % if frmValid
            %    figure;
            %    imshow(ycbcr2rgb(frmOut));
            % end
            %
            %   See also vision.ChromaResampler.
        end

        function DownsamplerWFilter(in) %#ok<MANU>
        end

        function LinearUpsampler(in) %#ok<MANU>
        end

        function PixelFormatter(in) %#ok<MANU>
            % PixelFormatter is called in the case of 4:4:4 to 4:2:2 
            % downsampling without a filter OR 4:2:2 to 4:4:4 upsample with 
            % pixel replication
            %--------------------------------------------------------------
            % Given an input stream of
            %   a x b x c x d x ... (where x represents values I don't care)
            % the output of PixelFormatter is
            %   a a b b c c d d ...
            %--------------------------------------------------------------
        end

        function getExecutionSemanticsImpl(in) %#ok<MANU>
            % works in both classic and synchronous subsystems
        end

        function getHeaderImpl(in) %#ok<MANU>
        end

        function getIconImpl(in) %#ok<MANU>
        end

        function getInputNamesImpl(in) %#ok<MANU>
        end

        function getNumInputsImpl(in) %#ok<MANU>
        end

        function getNumOutputsImpl(in) %#ok<MANU>
        end

        function getOutputDataTypeImpl(in) %#ok<MANU>
        end

        function getOutputNamesImpl(in) %#ok<MANU>
        end

        function getOutputSizeImpl(in) %#ok<MANU>
        end

        function getPropertyGroupsImpl(in) %#ok<MANU>
        end

        function isInactivePropertyImpl(in) %#ok<MANU>
        end

        function isOutputComplexImpl(in) %#ok<MANU>
        end

        function isOutputFixedSizeImpl(in) %#ok<MANU>
        end

        function loadObjectImpl(in) %#ok<MANU>
        end

        function outputImpl(in) %#ok<MANU>
            % output only, no updates
        end

        function resetImpl(in) %#ok<MANU>
            % restImpl: reset all the states
        end

        function saveObjectImpl(in) %#ok<MANU>
            % Save the public properties
        end

        function setupImpl(in) %#ok<MANU>
        end

        function showSimulateUsingImpl(in) %#ok<MANU>
        end

        function updateImpl(in) %#ok<MANU>
            % update states, no output
        end

        function validateInputsImpl(in) %#ok<MANU>
            %coder.extrinsic('validatecontrolsignals');            
        end

    end
    methods (Abstract)
    end
    properties
        %AntialiasingFilterSource Antialiasing filter
        %   Lowpass filter used to prevent aliasing
        %   Specify the lowpass filter used to prevent aliasing as one of
        %   ['Auto' | 'Property' | 'None']. If this property is set to
        %   'Auto', the System object uses a built-in lowpass filter. If this
        %   property is set to 'Property', the coefficients of the filters are
        %   specified by the properties HorizontalFilterCoefficients. If this 
        %   property is set to 'None', the System object does not filter the 
        %   input signal. This property is applicable when it downsamples the 
        %   chrominance values (i.e., the Resampling property is '4:4:4 to 4:2:2').
        AntialiasingFilterSource;

        %CustomCoefficientsDataType Custom coefficients data type
        %   Customize the coefficients data type. 
        %   The default setting is 'numerictype(1,16,15)'.
        %   The coefficients data type must be scaled and signed or unsigned.
        CustomCoefficientsDataType;

        %HorizontalFilterCoefficients Horizontal filter coefficients
        %   Specify the filter coefficients to apply to the input signal. This
        %   property is applicable when the Resampling property is '4:4:4 to 
        %   4:2:2' and the AntialiasingFilterSource property is 'Property'. 
        %   The default value of this property is [0.2 0.6 0.2].
        HorizontalFilterCoefficients;

        %InterpolationFilter Interpolation
        %   Specify the interpolation method used to approximate the missing
        %   chrominance values as one of ['Pixel replication' | 'Linear']. If
        %   this property is set to 'Linear', the System object uses linear
        %   interpolation to calculate the missing values. If this property is
        %   set to 'Pixel replication', the System object replicates the
        %   chrominance values of the neighboring pixels to create the
        %   upsampled image. This property is applicable when the Resampling 
        %   property is '4:2:2 to 4:4:4'. The default setting is 'Linear'.
        InterpolationFilter;

        %OverflowAction Overflow action
        %   Specify the overflow action as one of 
        %   [ 'Wrap' | 'Saturate']
        OverflowAction;

        %Resampling Resampling
        %   Specify the resampling format as one of
        %   [ '4:4:4 to 4:2:2' | '4:2:2 to 4:4:4' ].
        Resampling;

        %RoundingMethod Rounding method
        %   Specify the rounding method as one of
        %   [ 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Zero' ]
        RoundingMethod;

    end
end