In: Computer Science
I am trying to do edge detection using matlab. I have posted code here. It does not give any error but it's not running it at all. So please help me to fix it and also exaplin each line of this code pls. Thanks!
i = imread('C:\Users\Amanda\Desktop");
I = rgb2gray(1i);
BW1 = edge(I,'prewitt');
BW2= edge(I,'sobel');
BW3= edge(I,'roberts');
subplot (2,2,1);
imshow(I);
title('original');
subplot(2,2,2);
imshow(BW1);
title('Prewitt');
subplot(2,2,3);
imshow(BW2);
title('Sobel');
subplot(2,2,4);
imshow(BW3);
title('Roberts');
I have fixed the code which you posted, there are basically two errors.
Resolution
Following is the updated code
i = imread('RGB.png'); % This is reading the image from the file location specifies
I = rgb2gray(i); % Converting the image from RGB to Gray image
BW1 = edge(I,'prewitt'); % This is finding the edge in the image with prewitt as the method
BW2= edge(I,'sobel'); % This is finding the edge in the image with Sobel as the method
BW3= edge(I,'roberts'); % This is finding the edge in the image with roberts as the method
subplot (2,2,1); % This is making the plot in the area of 2*2 i.e 4 plots and this is the first(1) plot
imshow(I); % This will show the plot, whose space is aquired above, in the above line
title('original'); % Title for the above plot
subplot(2,2,2); % Acquiring space for the second plot
imshow(BW1); % Printing the second one in the space
title('Prewitt'); % Title for the above plot
subplot(2,2,3); % Making the space for the third plot
imshow(BW2); % Printing the third plot, whose space is allocated above.
title('Sobel'); % Title for the above plot
subplot(2,2,4); % Fourth plot Space
imshow(BW3); % Printing the plot
title('Roberts'); % Title for the same.
Following is the snippet of the output.
That was a nice question to answer
Friend, If you have any doubts in understanding do let me know in
the comment section. I will be happy to help you further.
Please like if you think effort deserves like.
Thanks
Figure 1 x + original Pre witt Sobel Roberts