No Code to Analyze Add code with code formatting and then click Analyze.

36 ビュー (過去 30 日間)
Adrian
Adrian 2025 年 3 月 14 日
コメント済み: Adrian 2025 年 3 月 14 日
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.');

採用された回答

Walter Roberson
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 ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by