【发布时间】:2019-11-15 04:37:47
【问题描述】:
我想请你帮忙定义线条粗细。我有二元曲线。我需要找出曲线骨架的每个点在法线方向上到线边缘的距离。所以,我首先计算了二元曲线的骨架。因此,对于骨架的每个像素,我计算了法线。图中描述了这种情况,显示了骨架和来自每个像素的法线向量图。在这一点上,我不知道如何计算每个骨架像素在法线方向上到曲线边缘的距离。实际上,我需要计算从骨架像素到法线方向的线边缘的像素数(逻辑 1)。这意味着我需要获取向量,其中包含每个骨架点的距离。我要提前感谢您的帮助。
用法线生成骨架的代码:
clc;clear all;close all
i=rgb2gray(imread('Bin_Lines.bmp'));
BW=bwskel(logical(i));
% BW = image sceleton
Orientations = skeletonOrientation(BW,5); %5x5 box
Onormal = Orientations+90; %easier to view normals
Onr = sind(Onormal); %vv
Onc = cosd(Onormal); %uu
[r,c] = find(BW); %row/cols
idx = find(BW); %Linear indices into Onr/Onc
figure()
imshow(BW,[]);
%Plotting normals of binary skeleton
hold on
quiver(c,r,-Onc(idx),Onr(idx));
这是我存储源代码和二进制行图像的链接:
https://www.dropbox.com/sh/j84ep3k1604hsza/AABm92TUBX6yIp29Gc0v_PHHa?dl=0
【问题讨论】:
标签: matlab image-processing computer-vision image-segmentation edge-detection