No Code to Analyze Add code with code formatting and then click Analyze.
37 次查看(过去 30 天)
显示 更早的评论
clc; clear; close all;
% Load the first image
img1 = imread('AdiTech.jpg'); % First image
img1_gray = rgb2gray(img1); % Convert to grayscale
% Load the second image
img2 = imread('Tema.png'); % Second image
img2_gray = rgb2gray(img2); % Convert to grayscale
% Apply edge detection operators on both images
edges_sobel1 = edge(img1_gray, 'sobel');
edges_prewitt1 = edge(img1_gray, 'prewitt');
edges_canny1 = edge(img1_gray, 'canny');
edges_sobel2 = edge(img2_gray, 'sobel');
edges_prewitt2 = edge(img2_gray, 'prewitt');
edges_canny2 = edge(img2_gray, 'canny');
% Display results for the first image
figure;
subplot(2,3,1), imshow(img1_gray), title('Image 1 - Grayscale);
subplot(2,3,2), imshow(edges_sobel1), title('Image 1 - Sobel');
subplot(2,3,3), imshow(edges_prewitt1), title('Image 1 - Prewitt');
subplot(2,3,4), imshow(edges_canny1), title('Image 1 - Canny');
% Display results for the second image
figure;
subplot(2,3,1), imshow(img2_gray), title('Image 2 - Grayscale');
subplot(2,3,2), imshow(edges_sobel2), title('Image 2 - Sobel');
subplot(2,3,3), imshow(edges_prewitt2), title('Image 2 - Prewitt');
subplot(2,3,4), imshow(edges_canny2), title('Image 2 - Canny');
% Save the processed images for both images
imwrite(edges_sobel1, 'edges_sobel_img1.png');
imwrite(edges_prewitt1, 'edges_prewitt_img1.png');
imwrite(edges_canny1, 'edges_canny_img1.png');
imwrite(edges_sobel2, 'edges_sobel_img2.png');
imwrite(edges_prewitt2, 'edges_prewitt_img2.png');
imwrite(edges_canny2, 'edges_canny_img2.png);
disp('Processing completed! The images have been saved.');
0 个评论
采纳的回答
Walter Roberson
2025-3-14
You could get that error if you were using LiveScript and you accidentally inserted your code using "Insert Text" instead of "Code"
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!