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

    classdef LookupTable< matlab.System & matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & matlab.system.mixin.Nondirect
%LookupTable  Specifies a one-to-one correspondance between the input pixel and ouput pixel according to table contents.
%  lut = visionhdl.LookupTable returns a System object, lut, that specifies 
%  a one-to-one correspondance between the input pixel and ouput pixel 
%  according to the lookup table contents.
%
%  lut = visionhdl.LookupTable(TABLEDATA) returns a System object, lut, 
%  with the table contents set to TABLEDATA.
%
%  Step method syntax:
%  [pixOut,ctrlOut] = step(lut,pixIn,ctrlIn)
%  gives the intensity value based on the input pixel value and the table
%  contents. 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.
%
%  LookupTable methods:
%
%   step     - See above description for use of this method
%   release  - Allow property value and input characteristics changes
%   clone    - Create median filter object with same property values
%   isLocked - Locked status (logical)
%
%  LookupTable properties:
%
%   Table - stores the table contents
%
%   % EXAMPLE: 
%   % Use lookup table as an inverter.
% frm2pix = visionhdl.FrameToPixels(...
%     'VideoFormat','custom',...
%     'ActivePixelsPerLine',32,...
%     'ActiveVideoLines',18,...
%     'TotalPixelsPerLine',42,...
%     'TotalVideoLines',28,...
%     'StartingActiveLine',6,...     
%     'FrontPorch',5);    
% [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);  
% 
% pix2frm = visionhdl.PixelsToFrame(...
%     'VideoFormat','custom',...
%     'ActivePixelsPerLine',actPixPerLine,...
%     'ActiveVideoLines',actLine);
% 
% inverter = visionhdl.LookupTable(...
%     'Table',uint8(255:-1:0)); 
% 
% frmFull = imread('rice.png');
% frmIn = frmFull(74:73+actLine,104:103+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(inverter,pixInVec(p),ctrlInVec(p));
% end
% [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
%     
% if frmValid
%    figure;
%    imshow(frmOut);
% end

 
%  Copyright 2014-2016 The MathWorks, Inc.

    methods
        function out=LookupTable
            %LookupTable  Specifies a one-to-one correspondance between the input pixel and ouput pixel according to table contents.
            %  lut = visionhdl.LookupTable returns a System object, lut, that specifies 
            %  a one-to-one correspondance between the input pixel and ouput pixel 
            %  according to the lookup table contents.
            %
            %  lut = visionhdl.LookupTable(TABLEDATA) returns a System object, lut, 
            %  with the table contents set to TABLEDATA.
            %
            %  Step method syntax:
            %  [pixOut,ctrlOut] = step(lut,pixIn,ctrlIn)
            %  gives the intensity value based on the input pixel value and the table
            %  contents. 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.
            %
            %  LookupTable methods:
            %
            %   step     - See above description for use of this method
            %   release  - Allow property value and input characteristics changes
            %   clone    - Create median filter object with same property values
            %   isLocked - Locked status (logical)
            %
            %  LookupTable properties:
            %
            %   Table - stores the table contents
            %
            %   % EXAMPLE: 
            %   % Use lookup table as an inverter.
            % frm2pix = visionhdl.FrameToPixels(...
            %     'VideoFormat','custom',...
            %     'ActivePixelsPerLine',32,...
            %     'ActiveVideoLines',18,...
            %     'TotalPixelsPerLine',42,...
            %     'TotalVideoLines',28,...
            %     'StartingActiveLine',6,...     
            %     'FrontPorch',5);    
            % [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);  
            % 
            % pix2frm = visionhdl.PixelsToFrame(...
            %     'VideoFormat','custom',...
            %     'ActivePixelsPerLine',actPixPerLine,...
            %     'ActiveVideoLines',actLine);
            % 
            % inverter = visionhdl.LookupTable(...
            %     'Table',uint8(255:-1:0)); 
            % 
            % frmFull = imread('rice.png');
            % frmIn = frmFull(74:73+actLine,104:103+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(inverter,pixInVec(p),ctrlInVec(p));
            % end
            % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
            %     
            % if frmValid
            %    figure;
            %    imshow(frmOut);
            % end
        end

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

        function getHeaderImpl(in) %#ok<MANU>
            %getHeaderImpl   Return header for object display
        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 isOutputComplexImpl(in) %#ok<MANU>
        end

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

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

        function outputImpl(in) %#ok<MANU>
            % outputImpl: send output
        end

        function resetImpl(in) %#ok<MANU>
        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>
            % updateImpl: update states
        end

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

    end
    methods (Abstract)
    end
    properties
        %Table Table data    
        %   The input pixel will be converted to an address indexing the table,
        %   and the output is the content of the specified table cell. The data
        %   type of the output follows that of the table data.
        Table;

    end
end