边缘链接 matlab,如何通过matlab中的边缘点绘制图像的平滑边界

这篇博客介绍了如何通过MATLAB处理二值图像,首先将图像阈值化,然后找出每列中的最低像素位置,并利用像素分辨率进行平滑处理。通过在最后一行填充NaN并重塑,找到最大行数,最后绘制出平滑后的边缘点。同时提到可以使用convhull函数创建凸包以获取更完整的边缘信息。
摘要由CSDN通过智能技术生成

这里是一个溶液

阈值图像,以便它仅仅是在二元的,容易的,因为这个图象很简单

确定每列中最低像素的位置

通过仅取第n列的最大值来平滑。 如果你只是想要最低点,那么你可以停止在下面的代码第4行!

代码被注释为更详细地:

img = rgb2gray(imread('1.jpg')); % Read image

img = img > 0.5; % Threshold to get binary image

% Get last row where there is a 1 pixel in the image for each column

lastrow = max(repmat((1:size(img,1))', 1, size(img,2)).*img,[],1);

res = 30; % Pixel resolution for line averaging

% Ensure res divides num. columns by padding the end of the vector

lastrowpadded = [lastrow, NaN(1, res - mod(numel(lastrow),res))];

% Reshape into columns of length 'res', then get the max row number

lastrow2 = max(reshape(lastrowpadded,res,[]),[],1);

% Plots

imshow(img);

hold on

plot(1:size(img,2), lastrow, '.')

plo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值