Compare commits

..
2 Commits
Author SHA1 Message Date
Cx330 1d78a43447 完成 2025-05-28 19:35:21 +08:00
Cx330 fbbdd89bf8 完成实验四 2025-05-28 19:33:10 +08:00
5 changed files with 82 additions and 3 deletions

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
% 读取图片
image = imread('EXP_3_4/test.jpg');
image_airport = imread('EXP_3_4/airport.jpg');
image_circuit = imread('EXP_3_4/circuit.png');
image_circle = imread('EXP_3_4/circle.jpg');
% 灰度化
image_gray = rgb2gray(image);
image_airport_gray = rgb2gray(image_airport);
image_circle_gray = rgb2gray(image_circle);
% log算法
image_log = edge(image_gray, 'log');
% canny算法
image_canny = edge(image_gray, 'canny');
image_circuit_canny = edge(image_circuit, 'canny');
% 角点检测
image_corners = corner(image_airport_gray, 'Harris');
% Hough参数
[Hough, theta, rho] = hough(image_circuit_canny);
% Hough 峰值
P = houghpeaks(Hough, 10, 'Threshold', ceil(0.3 * max(Hough(:)))); % 取前10个峰
% 峰值中提取图像中的直线
lines = houghlines(image_circuit_canny, theta, rho, P, 'FillGap', 20, 'MinLength', 30);
% 圆特征提取
[centers, radii] = imfindcircles(image_circle_gray, [50 100], 'ObjectPolarity', 'bright', 'Sensitivity', 0.92);
% 展示照片
figure;
subplot(1,3,1);
imshow(image);
title('Original Image'); % 原图
subplot(1,3,2);
imshow(image_log);
title('Log Edge Detection'); % Log边缘检测
subplot(1,3,3);
imshow(image_canny);
title('Canny Edge Detection'); % Canny边缘检测
figure;
subplot(1,2,1);
imshow(image_airport);
title('Original Image'); % 原图
subplot(1,2,2);
imshow(image_airport);
title('Corner Detection'); % 角点检测
hold on;
plot(image_corners(:,1), image_corners(:,2), 'r*');
% 显示图像与直线
figure;
imshow(image_circuit);
hold on;
title('Line Edge Detection'); %直线边缘检测
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2]; % 两端点
plot(xy(:,1), xy(:,2), 'LineWidth', 2, 'Color', 'green');
% 可视化端点
plot(xy(1,1), xy(1,2), 'x', 'Color', 'yellow');
plot(xy(2,1), xy(2,2), 'x', 'Color', 'red');
end
figure;
subplot(1,2,1);
imshow(image_circle);
title('Original Image'); % 原图
subplot(1,2,2);
imshow(image_circle);
title('Coin Edge Detection'); % 硬币边缘检测
hold on;
viscircles(centers, radii, 'EdgeColor', 'r');
+2 -2
View File
@@ -1,5 +1,5 @@
% 读取图片
image = imread('test.jpg');
image = imread('EXP_1_2/test.jpg');
% 灰度化处理
image_gray = rgb2gray(image);
@@ -14,7 +14,7 @@ image_sample2 = image(1:n:end, 1:n:end,:);
image_sample4 = image(1:m:end, 1:m:end,:);
% 图像叠加
image_2 = imread('photo.jpg');
image_2 = imread('EXP_1_2/photo.jpg');
image_add = imadd(image, image_2);
% 亮度增加
+1 -1
View File
@@ -1,5 +1,5 @@
% 读取图片
image = imread('test.jpg');
image = imread('EXP_1_2/test.jpg');
% 灰度化处理
image_gray = rgb2gray(image);
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB