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

    classdef EdgeDetector< matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & visionhdl.internal.abstractLineMemoryKernel & matlab.system.mixin.Nondirect
%EdgeDetector Finds edges of objects in images.
%  edgeDetect = visionhdl.EdgeDetector returns a System object, edgeDetect, 
%  that finds edges in an input image using Sobel, Prewitt, or Roberts 
%  algorithm.
%
%  edgeDetect = visionhdl.EdgeDetector('PropertyName',PropertyValue,...)
%  returns an edge detection object, edgeDetect, with each specified 
%  property set to the specified value.
% 
%  For Sobel, Prewitt, and Roberts algorithms, the object finds edges in an
%  input image by approximating the gradient magnitude of the image. The
%  gradient is obtained as a result of convolving the image with the Sobel, 
%  Prewitt, or Roberts kernel. 
%
%  Step method syntax:
%  [edge,ctrlOut] = step(edgeDetect,pixIn,ctrlIn)
%  finds the edges in input image using the specified algorithm when the 
%  BinaryImageOutputPort property is true. edge is a logical scalar with 
%  non-zero elements representing edge pixel and zero element representing 
%  background pixel. 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>.   
% 
%  [gv,gh,ctrlOut] = step(edgeDetect,pixIn,ctrlIn) 
%  finds the two gradient components, gv and gh, of the input image when 
%  the Method property is 'Sobel', 'Prewitt' or 'Roberts' and the 
%  GradientComponentOutputPorts property is true and the 
%  BinaryImageOutputPort property is false. If the Method property is
%  'Sobel' or 'Prewitt', gv is a matrix of gradient values in the vertical
%  direction and gh is a matrix of gradient values in the horizontal
%  direction. If the Method property is 'Roberts', gv represents the
%  gradient component at 45 degree edge response and gh represents the
%  gradient component at 135 degree edge response.
%
%  [edge,gv,gh,ctrlOut] = step(edgeDetect,pixIn,ctrlIn) 
%  finds the edges and the two gradient components of the input image when 
%  the Method property is 'Sobel', 'Prewitt', or 'Roberts' and both the 
%  BinaryImageOutputPort and GradientComponentOutputPorts properties are 
%  true.
% 
%  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.
%
%  EdgeDetector methods:
%
%   step     - See above description for use of this method
%   release  - Allow property value and input characteristics changes
%   clone    - Create edge detector object with same property values
%   isLocked - Locked status (logical)
%
%  EdgeDetector properties:
%
%   Method - Edge detection algorithm
%   BinaryImageOutputPort - Output the binary image
%   GradientComponentOutputPorts - Output the gradient components
%   ThresholdSource - Source of threshold value
%   Threshold - Threshold value
%   LineBufferSize - Line buffer size
%   RoundingMethod - Rounding method when a number cannot be represented exactly
%   OverflowAction - wrap or saturate in the case of overflow
%   GradientDataType - data type of the gradient components
%   CustomGradientDataType - customized data type of the gradient components
%
%   % EXAMPLE:
%   % Apply edge detector to 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);
% 
% sobel = visionhdl.EdgeDetector(...
%     'Threshold',7); 
% 
% frmFull = imread('rice.png');
% frmIn = frmFull(74:73+actLine,104:103+actPixPerLine);
% 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(sobel,pixInVec(p),ctrlInVec(p));
% end
% [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
%     
% if frmValid
%    figure;
%    imshow(frmOut);
% end
%
%   See also edge.

 
%   Copyright 2014-2016 The MathWorks, Inc.

    methods
        function out=EdgeDetector
            %EdgeDetector Finds edges of objects in images.
            %  edgeDetect = visionhdl.EdgeDetector returns a System object, edgeDetect, 
            %  that finds edges in an input image using Sobel, Prewitt, or Roberts 
            %  algorithm.
            %
            %  edgeDetect = visionhdl.EdgeDetector('PropertyName',PropertyValue,...)
            %  returns an edge detection object, edgeDetect, with each specified 
            %  property set to the specified value.
            % 
            %  For Sobel, Prewitt, and Roberts algorithms, the object finds edges in an
            %  input image by approximating the gradient magnitude of the image. The
            %  gradient is obtained as a result of convolving the image with the Sobel, 
            %  Prewitt, or Roberts kernel. 
            %
            %  Step method syntax:
            %  [edge,ctrlOut] = step(edgeDetect,pixIn,ctrlIn)
            %  finds the edges in input image using the specified algorithm when the 
            %  BinaryImageOutputPort property is true. edge is a logical scalar with 
            %  non-zero elements representing edge pixel and zero element representing 
            %  background pixel. 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>.   
            % 
            %  [gv,gh,ctrlOut] = step(edgeDetect,pixIn,ctrlIn) 
            %  finds the two gradient components, gv and gh, of the input image when 
            %  the Method property is 'Sobel', 'Prewitt' or 'Roberts' and the 
            %  GradientComponentOutputPorts property is true and the 
            %  BinaryImageOutputPort property is false. If the Method property is
            %  'Sobel' or 'Prewitt', gv is a matrix of gradient values in the vertical
            %  direction and gh is a matrix of gradient values in the horizontal
            %  direction. If the Method property is 'Roberts', gv represents the
            %  gradient component at 45 degree edge response and gh represents the
            %  gradient component at 135 degree edge response.
            %
            %  [edge,gv,gh,ctrlOut] = step(edgeDetect,pixIn,ctrlIn) 
            %  finds the edges and the two gradient components of the input image when 
            %  the Method property is 'Sobel', 'Prewitt', or 'Roberts' and both the 
            %  BinaryImageOutputPort and GradientComponentOutputPorts properties are 
            %  true.
            % 
            %  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.
            %
            %  EdgeDetector methods:
            %
            %   step     - See above description for use of this method
            %   release  - Allow property value and input characteristics changes
            %   clone    - Create edge detector object with same property values
            %   isLocked - Locked status (logical)
            %
            %  EdgeDetector properties:
            %
            %   Method - Edge detection algorithm
            %   BinaryImageOutputPort - Output the binary image
            %   GradientComponentOutputPorts - Output the gradient components
            %   ThresholdSource - Source of threshold value
            %   Threshold - Threshold value
            %   LineBufferSize - Line buffer size
            %   RoundingMethod - Rounding method when a number cannot be represented exactly
            %   OverflowAction - wrap or saturate in the case of overflow
            %   GradientDataType - data type of the gradient components
            %   CustomGradientDataType - customized data type of the gradient components
            %
            %   % EXAMPLE:
            %   % Apply edge detector to 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);
            % 
            % sobel = visionhdl.EdgeDetector(...
            %     'Threshold',7); 
            % 
            % frmFull = imread('rice.png');
            % frmIn = frmFull(74:73+actLine,104:103+actPixPerLine);
            % 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(sobel,pixInVec(p),ctrlInVec(p));
            % end
            % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec);    
            %     
            % if frmValid
            %    figure;
            %    imshow(frmOut);
            % end
            %
            %   See also edge.
        end

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

        function PrewittCoreFixedPoint(in) %#ok<MANU>
            %if ~isa(in,'double') && ~isa(in,'single') % fi or INTN/UINTN                
        end

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

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

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

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

        function SobelCoreFloatingPoint(in) %#ok<MANU>
        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 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, no state update
        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>
            % update states, no output
        end

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

    end
    methods (Abstract)
    end
    properties
        %BinaryImageOutputPort Output the binary image
        %   Set this property to true to output the binary image after edge
        %   detection. When this property is set to true, the object will
        %   output a logical matrix. The nonzero elements of this matrix
        %   correspond to the edge pixels and the zero elements correspond to
        %   the background pixels. The default value for this property is true.
        BinaryImageOutputPort;

        %CustomGradientDataType Custom gradient date type
        %  Customize the gradient data type when OutputDataType is
        %  selected as 'Custom', default is 'numerictype(1,8,0)'. 
        % The gradient data type must be scaled and signed or unsigned.
        CustomGradientDataType;

        %GradientComponentOutputPorts Output the gradient components
        %   Set this property to true to output the gradient components after
        %   edge detection. When this property is set to true, and the Method
        %   property is set to 'Sobel' or 'Prewitt', this System object outputs
        %   the gradient components that correspond to the horizontal and
        %   vertical edge responses. When the Method property is set to
        %   'Roberts', the System object outputs the gradient components that
        %   correspond to the 45 and 135 degree edge responses. Both
        %   BinaryImageOutputPort and GradientComponentOutputPorts properties
        %   cannot be false at the same time. The default value for this
        %   property is false.
        GradientComponentOutputPorts;

        %GradientDataType Gradient data type
        %  Specify the gradient data type as one of 
        %  [ 'Same as first input' | 'Full precision' | 'Custom' ]
        GradientDataType;

        %LineBufferSize Line buffer size
        %   Specify the size of the line buffer. The value should be greater 
        %   than or equal to the number of active pixels per line.
        %   The default value of this property is 2048.
        LineBufferSize;

        %Method Method
        %   Specify the edge detection algorithm as one of ['Sobel' | 'Prewitt' 
        %   | 'Roberts'].
        Method;

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

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

        %Threshold Threshold value
        %   Specify the threshold value. This property is accessible when the 
        %   ThresholdSource property is 'Property'.
        %   The default value of this property is 20.
        Threshold;

        %ThresholdSource Source of threshold value
        %   Specify how to determine threshold as one of ['Property' | 
        %   'Input port']. This property is accessible when the
        %   BinaryImageOutputPort property is true.
        ThresholdSource;

    end
end