Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Computer vision 如何计算纤维长度_Computer Vision - Fatal编程技术网

Computer vision 如何计算纤维长度

Computer vision 如何计算纤维长度,computer-vision,Computer Vision,我需要帮助计算纤维长度。利用欧氏距离的区域极大值求出纤维中心线的所有坐标值。这是我应用欧氏距离的区域最大值后得到的图像。现在,我想通过使用这些点在每根光纤上画一条线,如何才能做到这一点,以便自动提取每根光纤的长度。我试着用样条曲线拟合。但问题是我无法启动光纤的起点和终点。如何计算每根光纤的长度 全部关闭; 清除所有; clc ima=imread('ecm61.png'); ima=BWAREOPEN(ima,50); [行图像,列图像]=大小(ima); skel=bwmorph(ima,

我需要帮助计算纤维长度。利用欧氏距离的区域极大值求出纤维中心线的所有坐标值。这是我应用欧氏距离的区域最大值后得到的图像。现在,我想通过使用这些点在每根光纤上画一条线,如何才能做到这一点,以便自动提取每根光纤的长度。我试着用样条曲线拟合。但问题是我无法启动光纤的起点和终点。如何计算每根光纤的长度


全部关闭;
清除所有;
clc
ima=imread('ecm61.png');
ima=BWAREOPEN(ima,50);
[行图像,列图像]=大小(ima);
skel=bwmorph(ima,'skel',Inf);
图形
imshow(skel)
B=bwmorph(skel,“分支点”);
E=bwmorph(skel,“端点”);
[x,y]=找到(E);
%绘图(x,y,“+”)
B_loc=查找(B);
Dmask=false(大小(skel));
对于k=1:numel(y)
D=测地线(skel,y(k),x(k));
距离分支点=最小值(D(B_-loc));
Dmask(D
我会这样做:

  • 骨骼化
  • 在每个交叉点找到不同的路径。它将为您提供不同的线段,您可以使用方向重新连接它们

  • 谢谢。但我有几个问题。什么是修剪?我怎样才能在每个十字路口找到不同的路径?我有一个修剪的链接,但你在谷歌上还有很多其他的链接。这是移除小树枝的操作。有两个以上邻居的像素是一个交叉点,交叉点是路径的端点。谢谢。我将遵循这个想法。我先做了2个。我如何才能找到方向?有两个以上邻居的像素位于一个交叉点!以后,请将您的代码编辑到您的问题中,而不是将其作为答案发布。此外,我建议你编辑你的问题,以便更准确地说明哪些问题不起作用;目前还不完全清楚。
       close all;
    clear all;
    clc
    ima=imread('ecm61.png');
    ima=bwareaopen(ima,50);
    [rowsInImage,columnImage]=size(ima);
    skel= bwmorph(ima,'skel',Inf);
    figure 
    imshow(skel)
    B = bwmorph(skel, 'branchpoints');
    E = bwmorph(skel, 'endpoints');
    [x,y] = find(E);
    %plot(x,y,'+')
    B_loc = find(B);
    Dmask = false(size(skel));
    for k = 1:numel(y)
        D = bwdistgeodesic(skel,y(k),x(k));
        distanceToBranchPt = min(D(B_loc));
        Dmask(D < distanceToBranchPt) =true;
    end
    skelD = skel - Dmask;
    
    figure
    imshow(skelD);
    hold all;
    [x,y] = find(B); plot(y,x,'ro')
    numberOfEndpoints=length(y);
    % Label the image.  Gives each separate segment a unique ID label number.
    [labeledImage, numberOfSegments] = bwlabel(skelD);
    fprintf('There are %d endpoints on %d segments.\n', numberOfEndpoints, numberOfSegments);
    % Get the label numbers (segment numbers) of every endpoint.
    for k = 1 : numberOfEndpoints
        thisRow = x(k);
        thisColumn = y(k);
        %line([endPointRows(k),endPointColumns(k)],[endPointRows(k+1),endPointColumns(k+1)])
        % Get the label number of this segment
        theLabels(k) = labeledImage(thisRow, thisColumn);
        fprintf('Endpoint #%d at (%d, %d) is in segment #%d.\n', k, thisRow, thisColumn, theLabels(k));
    end
    
    % For each endpoint, find the closest other endpoint
    % that is not in the same segment
    for k = 1 : numberOfEndpoints
        thisRow = x(k);
        thisColumn =y(k);
        % Get the label number of this segment
        thisLabel = theLabels(k);
    
        otherEndpointIndexes = setdiff(1:numberOfEndpoints, k);
        %if mustBeDifferent
            % If they want to consider joining only end points that reside on different segments
            % then we need to remove the end points on the same segment from the "other" list.
            % Get the label numbers of the other end points.
            %otherLabels = theLabels(otherEndpointIndexes);
            %onSameSegment = (otherLabels == thisLabel); % List of what segments are the same as this segment
            %otherEndpointIndexes(onSameSegment) = []; % Remove if on the same segment
        %end
    
        % Now get a list of only those end points that are on a different segment.
        otherCols = y(otherEndpointIndexes);
        otherRows = x(otherEndpointIndexes);
    
        % Compute distances
        distances = sqrt((thisColumn - otherCols).^2 + (thisRow - otherRows).^2);
        % Find the min
        [minDistance, indexOfMin] = min(distances);
        nearestX = otherCols(indexOfMin);
        nearestY = otherRows(indexOfMin);
    
        %if minDistance < longestGapToClose;
        if minDistance < rowsInImage
            % Draw line from this endpoint to the other endpoint.
            line([thisColumn, nearestX], [thisRow, nearestY], 'Color', 'g', 'LineWidth', 2);
            fprintf('Drawing line #%d, %.1f pixels long, from (%d, %d) on segment #%d to (%d, %d) on segment #%d.\n', ...
                k, minDistance, thisColumn, thisRow, theLabels(k), nearestX, nearestY, theLabels(indexOfMin));
        end
    end
    title('Endpoints Linked by Green Lines', 'FontSize', 12, 'Interpreter', 'None');