No Code to Analyze Add code with code formatting and then click Analyze.
조회 수: 21 (최근 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!