Edge detection using in-built function in MATLAB

25 Aug, 2021
Edge detection: In an image, an edge is a curve that follows a path of rapid change in intensity of that image. Edges are often associated with the boundaries of the object in a scene environment. Edge detection is used to identify the edges in an image to make image processing easy. Edge detection works by detecting discontinuities in brightness. Edge detection is mainly used for image segmentation and data extraction in areas such as image processing, computer vision, and machine vision. 
To find edges, you can use the in-built edge function edge(image, Edge detector) of Matlab. This in-built function looks for places in the image where the intensity changes rapidly, using one of these two criteria:  
Places where the first derivative of the intensity is larger in magnitude than some threshold value.
Places where the second derivative of the intensity has a zero crossing.
Edge detectors provide several derivative estimators, each of which implements one of the above stated definitions. For some of these estimators, you can specify whether the operation should be sensitive to vertical edges, horizontal edges, or both. Edge estimators return a binary image containing 1’s where edges are found and 0’s elsewhere. 
The most powerful edge-detection technique that edge provides is the Canny method. The Canny method differs from the other edge-detection methods in that it uses two different types of thresholds levels to detect strong and weak edges. The Canny edge detection method includes the weak edges in the output only if they are connected to strong edges. This method is, therefore, less likely to be affected by noise, and more likely to detect true weak edges. 
There are many Edge detection in-built functions are available in Matlab like:  
Sobel edge detector
Prewitt edge detector
Robert edge detector
Log edge detector
Zerocross edge detector
Canny edge detector
Edge detection using MATLAB library function. 
Matlab
% importing the imageI = rgb2gray(imread("flowers.jpg"));subplot(2, 4, 1),imshow(I);title("Gray Scale Image"); % Sobel Edge DetectionJ = edge(I, 'Sobel');subplot(2, 4, 2),imshow(J);title("Sobel"); % Prewitt Edge detectionK = edge(I, 'Prewitt');subplot(2, 4, 3),imshow(K);title("Prewitt"); % Robert Edge DetectionL = edge(I, 'Roberts');subplot(2, 4, 4),imshow(L);title("Robert"); % Log Edge DetectionM = edge(I, 'log');subplot(2, 4, 5),imshow(M);title("Log"); % Zerocross Edge DetectionM = edge(I, 'zerocross');subplot(2, 4, 6),imshow(M);title("Zerocross"); % Canny Edge DetectionN = edge(I, 'Canny');subplot(2, 4, 7),imshow(N);title("Canny");
Output:
 
sagartomar9927
Image-Processing
MATLAB
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Monte Carlo Tree Search (MCTS)
Markov Decision Process
Basics of API Testing Using Postman
Copying Files to and from Docker Containers
Getting Started with System Design
Principal Component Analysis with Python
How to create a REST API using Java Spring Boot
Monolithic vs Microservices architecture
Fuzzy Logic | Introduction
Mounting a Volume Inside Docker Container