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

    classdef Erosion< visionhdl.internal.abstractLineMemoryKernel & matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & matlab.system.mixin.Nondirect
%Erosion Performs morphological erosion on a binary image.
%  morphErode = visionhdl.Erosion returns a System object, morphErode, 
%  that performs morphological erosion of an input stream based on the
%  input control signals.
%
%  morphErode = visionhdl.Erosion('PropertyName',PropertyValue,...)
%  returns an erosion System object, morphErode, with each specified
%  property set to the specified value.
%
%  morphErode = visionhdl.Erosion(Nhood,'PropertyName',PropertyValue,...) 
%  returns an erosion System object, morphErode, with the Neighborhood
%  property set to Nhood, other specified properties set to the 
%  specified values.
%
%  Step method syntax: 
%  [pixOut,ctrlOut] = step(morphErode,pixIn,ctrlIn) performs 
%  morphological erosion. 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.
%
%  Erosion 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)
%
%  Erosion properties:
%
%   Neighborhood      - Neighborhood values
%   LineBufferSize    - Line buffer size
%
% % EXAMPLE:
% % Perform morphological erosion on an image.
% 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);
%
% morphErode = visionhdl.Erosion;
%
% frmFull = imread('peppers.png');
% frmIn = imresize(rgb2gray(frmFull),[actLine actPixPerLine])>100;
% imshow(frmIn);
%
% pixOutVec = false(numPixPerFrm,1);
% ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
%
% [pixInVec,ctrlInVec] = step(frm2pix,frmIn);
% for p = 1:numPixPerFrm
%     [pixOutVec(p),ctrlOutVec(p)] = step(morphErode,pixInVec(p),ctrlInVec(p));
% end
% [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);
%
% if frmValid
%     figure;
%     imshow(frmOut);
% end
%
%   See also imerode.

     
    %   Copyright 2014-2016 The MathWorks, Inc.

    methods
        function out=Erosion
            %Erosion Performs morphological erosion on a binary image.
            %  morphErode = visionhdl.Erosion returns a System object, morphErode, 
            %  that performs morphological erosion of an input stream based on the
            %  input control signals.
            %
            %  morphErode = visionhdl.Erosion('PropertyName',PropertyValue,...)
            %  returns an erosion System object, morphErode, with each specified
            %  property set to the specified value.
            %
            %  morphErode = visionhdl.Erosion(Nhood,'PropertyName',PropertyValue,...) 
            %  returns an erosion System object, morphErode, with the Neighborhood
            %  property set to Nhood, other specified properties set to the 
            %  specified values.
            %
            %  Step method syntax: 
            %  [pixOut,ctrlOut] = step(morphErode,pixIn,ctrlIn) performs 
            %  morphological erosion. 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.
            %
            %  Erosion 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)
            %
            %  Erosion properties:
            %
            %   Neighborhood      - Neighborhood values
            %   LineBufferSize    - Line buffer size
            %
            % % EXAMPLE:
            % % Perform morphological erosion on an image.
            % 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);
            %
            % morphErode = visionhdl.Erosion;
            %
            % frmFull = imread('peppers.png');
            % frmIn = imresize(rgb2gray(frmFull),[actLine actPixPerLine])>100;
            % imshow(frmIn);
            %
            % pixOutVec = false(numPixPerFrm,1);
            % ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);
            %
            % [pixInVec,ctrlInVec] = step(frm2pix,frmIn);
            % for p = 1:numPixPerFrm
            %     [pixOutVec(p),ctrlOutVec(p)] = step(morphErode,pixInVec(p),ctrlInVec(p));
            % end
            % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);
            %
            % if frmValid
            %     figure;
            %     imshow(frmOut);
            % end
            %
            %   See also imerode.
        end

        function ComputeErosion(in) %#ok<MANU>
            %         obj.kWidthCnt =  obj.kWidthCnt+1;
            %         if obj.kWidthCnt > obj.kWidth
            %             obj.kWidthCnt = 1;
            %         end
            % %         mval = false;
            %         nhood = obj.Neighborhood(:,obj.kWidthCnt);
            %
            %            sdata = false(obj.kHeight,1);
            %         % or with inversed neighbor
            %         for i = 1:obj.kHeight
            %             sdata(i) = or(dataCol(i,1),not(nhood(i,1)));
            %         end
            %          % dialtion bitor
            %           t = sdata(1);
            %           for i = 2:obj.kHeight
            %             t = and(t,sdata(i));
            %           end
            %           %shift reg
            %           obj.bitopReg(obj.kWidth:-1:2,1) =  obj.bitopReg(obj.kWidth-1:-1:1,1);
            %           obj.bitopReg(1,1) = t;
            %           %dialation final bitor
            %           for j = 2:obj.kWidth
            %               t = and(t,obj.bitopReg(j));
            %           end
            %           mval = t;
        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, 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>
            %coder.extrinsic('validatecontrolsignals');
        end

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

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

    end
    methods (Abstract)
    end
    properties
        %LineBufferSize Line buffer size
        %   Specify the maximum number of pixels in a horizontal line as an
        %   positive integer. The default value of this property is 2048.
        LineBufferSize;

        %Neighborhood
        Neighborhood;

    end
end