- 积分
- 1016
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 110
- 最后登录
- 1970-1-1
签到天数: 5 天 连续签到: 4 天 [LV.2]偶尔看看I
|
发表于 2025-7-23 09:27
|
显示全部楼层
来自: 中国辽宁锦州
% 1. 读取图片
img = imread('curve.jpg');
gray_img = rgb2gray(img);
% 2. 二值化
bw_img = imbinarize(gray_img);
% 3. 骨架化
skeleton = bwmorph(bw_img, 'thin', Inf);
% 4. 提取坐标
[y, x] = find(skeleton);
[x_sorted, idx] = sort(x);
y_sorted = y(idx);
% 5. 显示结果
figure;
subplot(1,2,1); imshow(skeleton); title('骨架化图像');
subplot(1,2,2); plot(x_sorted, y_sorted, 'b-'); title('提取的曲线');
axis ij;
% 6. 保存数据
save('curve_points.mat', 'x_sorted', 'y_sorted'); |
|