Matlab 计算法线方向上的二进制线厚度

Matlab 计算法线方向上的二进制线厚度,matlab,image-processing,computer-vision,image-segmentation,edge-detection,Matlab,Image Processing,Computer Vision,Image Segmentation,Edge Detection,我想请您帮助定义线的厚度。我有一条二元曲线。我需要找出曲线骨架的每个点到法线方向的直线边的距离。所以,我首先计算了二元曲线的骨架。因此,对于骨架的每个像素,我计算法线。图中描述了这种情况,显示了每个像素的法向量的骨架和贴图。在这一点上,我不知道如何计算每个骨架像素到法线方向上的曲线边的距离。实际上,我需要在法线方向上计算从骨架像素到线边缘的像素数(逻辑1)。这意味着我需要获得向量,包含每个骨架点的距离。我想提前感谢你的帮助 用于生成具有法线的骨架的代码: clc;clear all;close

我想请您帮助定义线的厚度。我有一条二元曲线。我需要找出曲线骨架的每个点到法线方向的直线边的距离。所以,我首先计算了二元曲线的骨架。因此,对于骨架的每个像素,我计算法线。图中描述了这种情况,显示了每个像素的法向量的骨架和贴图。在这一点上,我不知道如何计算每个骨架像素到法线方向上的曲线边的距离。实际上,我需要在法线方向上计算从骨架像素到线边缘的像素数(逻辑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));
这是我存储源代码和二进制行图像的链接:

您可以使用来计算每个内部像素到边界的距离。Matlab必须为您做到这一点。
然后可以提取骨架像素的信息

img = rgb2gray(imread('Bin_Lines.bmp'));  
bw = bwskel(img > 128);
dst = bwdist(img <= 128);  % need opposite contrast
distance_of_skel_pixels_to_boundary = dst(bw)
img=rgb2gray(imread('Bin_Lines.bmp');
bw=bwskel(img>128);
dst=bwdist(img您可以使用它来计算每个内部像素到边界的距离。Matlab必须为您这样做。
然后可以提取骨架像素的信息

img = rgb2gray(imread('Bin_Lines.bmp'));  
bw = bwskel(img > 128);
dst = bwdist(img <= 128);  % need opposite contrast
distance_of_skel_pixels_to_boundary = dst(bw)
img=rgb2gray(imread('Bin_Lines.bmp');
bw=bwskel(img>128);

亲爱的Shai,非常感谢你。它看起来很好,对我很有用。Jordula11很高兴我能帮上忙。如果这个答案对你有用,请点击“V”来“接受”它。图标旁边的itDear Shai,非常感谢。它看起来非常好和有用的我。@ Junula11高兴我能帮助。如果这个答案对你有用,请考虑“接受”它点击“V”图标旁边。