EDGE function ERROR
古いコメントを表示
I'm trying to perform the following operation
%Load the image into matlab
A = imread('before3.jpg');
%Show the image
figure(1)
imshow(A)
I = edge(A, 'sobel');
Using this high pass filter I expect to find the edges of my image but I get the following error while using the edge function.
??? Function EDGE expected its first input, I, to be two-dimensional.
Error in ==> edge>parse_inputs at 564
iptcheckinput(I,{'numeric'},{'nonsparse','2d'},mfilename,'I',1);
Error in ==> edge at 197
[a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
Error in ==> image1 at 21
I = edge(A,'sobel');
The image 'before3.jpg' has value
<1728x2304x3 uint8>
The error says to use a 2 dimensional input but I have not been able to find a way to change my image to a 2 dimensional matrix and keep at the same time the original edges.
I tried
[X, map] = rgb2ind(A,256);
I used as the map a 'gray' scale but it did not work.
Please if you have a different approach that you can recommend me I will be very grateful.
回答 (7 件)
EFECTIVAMENTE AMIGO, LA FUNCION edge SOLO ADMITE IMAGEN ES ESCALAS GRISES, REALIZA LO SIGUIENTE:
%para leer una imagen
I = imread('casa.jpg');
%% convertir a escalas grises
I=rgb2gray(I);
%hallando contorno
BW = edge(I);
%mostrando contorno
imshow(BW)
slds,
Joel Villavicencio
3 件のコメント
bharat arora
2016 年 6 月 5 日
thanks
Muddasar Khan
2018 年 2 月 19 日
Yes, You are right. We should convert colored image to gray image then edges should be detected
princess sofiya
2020 年 4 月 12 日
thanks too.
Walter Roberson
2011 年 11 月 17 日
2 投票
rgb2gray() rather than rgb2ind()
Jan
2011 年 11 月 17 日
In the help text of edge I find:
W = edge(I) takes a grayscale or a binary image I as its input...
1 件のコメント
SUBBARAMIREDDY YERUVA
2023 年 12 月 4 日
Thanks alot
Alex
2011 年 11 月 17 日
1 投票
according to the documentation, using imread with a jpeg object results in RGB scale. As in, each pixel is represented by a 3 element vector ['red value' 'green value' 'blue value'];
1 件のコメント
Walter Roberson
2018 年 2 月 19 日
Not universally true. There are true grayscale jpeg images. But I have only ever encountered one, apart from test images to prove that they exist. Jpeg is nearly always rgb. Never pseudocolor though.
Eulises Ulloa
2011 年 11 月 17 日
0 投票
3 件のコメント
Walter Roberson
2011 年 11 月 17 日
The places that used edge() right after imread() were places where the image being read was grayscale.
Jan
2011 年 11 月 17 日
If you want to use the edge-detection on an RGB image, you cannot use the EDGE function. There are a lot of edge-detection methods in the FEX: http://www.mathworks.com/matlabcentral/fileexchange/?term=edge
There are other methods to convert the image to gray-scale also. Consider to sharpen the edges in the HSV color-space at first.
Eulises Ulloa
2011 年 11 月 17 日
Priscil23
2018 年 2 月 15 日
0 投票
Just as everyone said, first convert your rgb2gray then to view the output after your desired edge functions use imshow to view the image. I faced the same problem.
priyanka nale
2019 年 12 月 30 日
close all;
clear ;
I=imread('4.jpg');
figure,imshow(I)
I=rgb2gray(I);
c= edge(I,'sobel');
figure,imshow(c);
カテゴリ
ヘルプ センター および File Exchange で Object Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!