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

    classdef ColorSpaceConverter< matlab.System & matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & matlab.system.mixin.Nondirect
%ColorSpaceConverter Converts color information between color spaces.
%  csc = visionhdl.ColorSpaceConverter returns a System object, csc,
%  converts color information between color spaces.
%
%  csc = visionhdl.ColorSpaceConverter('PropertyName',PropertyValue,...)
%  returns a color space conversion object, csc, with each specified
%  property set to the specified value.
%
%  Step method syntax:
%  [pixOut,ctrlOut] = step(csc,pixIn,ctrlIn) converts a single pixel from 
%  one color space to another. 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.
%
%  ColorSpaceConverter methods:
%
%   step     - See above description for use of this method
%   release  - Allow property value and input characteristics changes
%   clone    - Create a Color Space Converter System object with same property values
%   isLocked - Locked status (logical)
%
%  ColorSpaceConverter properties:
%
%   Conversion - Color spaces you are converting between.
%   ConversionStandard - The standard to convert pixel values between the 
%                RGB and YCbCr color spaces
%   ScanningStandard - The scanning standard to use to convert your values 
%                between the RGB and YCbCr color spaces
%
%   % EXAMPLE:
%   % Convert a color image to grayscale
% 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(...
%     'VideoFormat','custom',...
%     'ActivePixelsPerLine',actPixPerLine,...
%     'ActiveVideoLines',actLine);
% 
% rgb2gray = visionhdl.ColorSpaceConverter(...
%     'Conversion','RGB to intensity');
% 
% frmFull = imread('pears.png');
% frmIn = imresize(frmFull,[actLine actPixPerLine]);
% imshow(frmIn);
%
% pixOutVec = zeros(numPixPerFrm,1,'uint8');
% ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
% 
% [pixInVec,ctrlInVec] = step(frm2pix,frmIn);
% for p = 1:numPixPerFrm    
%     [pixOutVec(p),ctrlOutVec(p)] = step(rgb2gray,pixInVec(p,:),ctrlInVec(p));
% end
% [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
%     
% if frmValid
%    figure;
%    imshow(frmOut);
% end
%
%   See also vision.ColorSpaceConverter, rgb2ycbcr, ycbcr2rgb, rgb2gray.

 
%   Copyright 2014-2016 The MathWorks, Inc.

    methods
        function out=ColorSpaceConverter
            %ColorSpaceConverter Converts color information between color spaces.
            %  csc = visionhdl.ColorSpaceConverter returns a System object, csc,
            %  converts color information between color spaces.
            %
            %  csc = visionhdl.ColorSpaceConverter('PropertyName',PropertyValue,...)
            %  returns a color space conversion object, csc, with each specified
            %  property set to the specified value.
            %
            %  Step method syntax:
            %  [pixOut,ctrlOut] = step(csc,pixIn,ctrlIn) converts a single pixel from 
            %  one color space to another. 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.
            %
            %  ColorSpaceConverter methods:
            %
            %   step     - See above description for use of this method
            %   release  - Allow property value and input characteristics changes
            %   clone    - Create a Color Space Converter System object with same property values
            %   isLocked - Locked status (logical)
            %
            %  ColorSpaceConverter properties:
            %
            %   Conversion - Color spaces you are converting between.
            %   ConversionStandard - The standard to convert pixel values between the 
            %                RGB and YCbCr color spaces
            %   ScanningStandard - The scanning standard to use to convert your values 
            %                between the RGB and YCbCr color spaces
            %
            %   % EXAMPLE:
            %   % Convert a color image to grayscale
            % 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(...
            %     'VideoFormat','custom',...
            %     'ActivePixelsPerLine',actPixPerLine,...
            %     'ActiveVideoLines',actLine);
            % 
            % rgb2gray = visionhdl.ColorSpaceConverter(...
            %     'Conversion','RGB to intensity');
            % 
            % frmFull = imread('pears.png');
            % frmIn = imresize(frmFull,[actLine actPixPerLine]);
            % imshow(frmIn);
            %
            % pixOutVec = zeros(numPixPerFrm,1,'uint8');
            % ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
            % 
            % [pixInVec,ctrlInVec] = step(frm2pix,frmIn);
            % for p = 1:numPixPerFrm    
            %     [pixOutVec(p),ctrlOutVec(p)] = step(rgb2gray,pixInVec(p,:),ctrlInVec(p));
            % end
            % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
            %     
            % if frmValid
            %    figure;
            %    imshow(frmOut);
            % end
            %
            %   See also vision.ColorSpaceConverter, rgb2ycbcr, ycbcr2rgb, rgb2gray.
        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 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>
            % send output, do not update states
        end

        function resetImpl(in) %#ok<MANU>
            % reset 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
        %Conversion Conversion
        %   Specify the color spaces you are converting between.
        %   [ 'RGB to YCbCr' | 'YCbCr to RGB' | 'RGB to intensity' ]. 
        Conversion;

        %ConversionStandard Use conversion specified by
        %   Specify the standard to convert pixel values between the RGB 
        %   and YCbCr color spaces. Your choices are 
        %   [ 'Rec. 601 (SDTV)' | 'Rec. 709 (HDTV)' ]
        ConversionStandard;

        %ScanningStandard Scanning standard
        %   Specify the scanning standard to use to convert your values between 
        %   the RGB and YCbCr color spaces. Your choices are 
        %   [ '1125/60/2:1' | '1250/50/2:1' ]
        ScanningStandard;

    end
end