You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
% Read the image
img = imread('C:\Program Files (x86)\IMG-20240221-WA0003.jpg');
% Convert the image to grayscale if it's a color image
if size(img, 3) == 3
img_gray = rgb2gray(img);
else
img_gray = img;
end
% Perform edge detection using the Sobel method
edges_sobel = edge(img_gray, 'Sobel');
% Perform edge detection using the Prewitt method
edges_prewitt = edge(img_gray, 'Prewitt');
% Display the original image and the detected edges using Sobel and Prewitt
figure;
subplot(1, 3, 1);
imshow(img);
title('Original Image');
subplot(1, 3, 2);
imshow(edges_sobel);
title('Edges Detected (Sobel)');
subplot(1, 3, 3);
imshow(edges_prewitt);
title('Edges Detected (Prewitt)');
Cite As
Emmanuel (2026). % Read the image img = imread('C:\Program Files (x86)\IMG-20 (https://www.mathworks.com/matlabcentral/fileexchange/160138-read-the-image-img-imread-c-program-files-x86-img-20), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0 (253 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0 |
|
