% Read the image img = imread('C:\Program Files (x86)\IMG-20

Version 1.0.0 (253 KB) by Emmanuel
% 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
7 Downloads
Updated 25 Feb 2024

View License

% 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 .

MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0