No Code to Analyze Add code with code formatting and then click Analyze.
36 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Adrian
el 14 de Mzo. de 2025
Comentada: Adrian
el 14 de Mzo. de 2025
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 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Mzo. de 2025
You could get that error if you were using LiveScript and you accidentally inserted your code using "Insert Text" instead of "Code"
Más respuestas (0)
Ver también
Categorías
Más información sobre Modify Image Colors en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!