MATLAB Answers

0

error using edge sobel

Asked by Jürgen Lederer on 7 Apr 2017
Latest activity Answered by Saurabh Gupta on 12 Apr 2017
Hello!
I get the following error message:
Error using edge Expected input number 1, I, to be two-dimensional.
Error in edge>parse_inputs (line 476)
validateattributes(I,{'numeric','logical'},{'real','nonsparse','2d'},mfilename,'I',1);
Error in edge (line 208)
[a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
Error in V01_06042017 (line 3)
BW1 = edge(I,'sobel');
Code:
I = imread('Bild.tif');
BW1 = edge(I,'sobel');
imshow (BW1);
line 476: validateattributes(I,{'numeric','logical'},{'real','nonsparse','2d'},mfilename,'I',1);
line208: [a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
Can anyone help me Thank you very much

  0 Comments

Sign in to comment.

1 Answer

Answer by Saurabh Gupta on 12 Apr 2017

As the error mentions, the variable 'I' is expected to be 2-D . Verify if that is the case. I'm guessing that your image is a color image and imread returns 3-D data.
If your image uses CMYK, you may find this post helpful for converting your data to RGB.
RGB image data can be converted to grayscale or indexed using rgb2gray or rgb2ind respectively, which can then be used in the edge function.

  0 Comments

Sign in to comment.