error using edge sobel

21 views (last 30 days)
Jürgen Lederer
Jürgen Lederer on 7 Apr 2017
Answered: Saurabh Gupta on 12 Apr 2017
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)
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');
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

Answers (1)

Saurabh Gupta
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!