matlab - 等值线图水平值的总和

标签 matlab plot contour

我正在尝试计算轮廓内的级别(z 轴)值的总和:enter image description here

我已经成功获得了轮廓的线(或边缘),因此我得到了每条线的限制:

enter image description here

我想要的是对第二个图中外部蓝线内部的轮廓 z 轴上的所有级别进行求和,以将其与蓝线外部的值的总和进行比较。有什么办法可以做到这一点吗?到目前为止我的代码是:

   C = contourc(f, t, abs(tfr));

%extracts info from contour    
    sz = size(C,2);     % Size of the contour matrix c
    ii = 1;             % Index to keep track of current location
    jj = 1;             % Counter to keep track of # of contour lines

    while ii < sz       % While we haven't exhausted the array
        n = C(2,ii);    % How many points in this contour?
        s(jj).v = C(1,ii);        % Value of the contour
        s(jj).x = C(1,ii+1:ii+n); % X coordinates
        s(jj).y = C(2,ii+1:ii+n); % Y coordinates
        ii = ii + n + 1;          % Skip ahead to next contour line
        jj = jj + 1;              % Increment number of contours
    end

最佳答案

因此,在运行问题中的代码后,您将在数组 S 中获得每个轮廓的坐标。假设您有以下形式的变量 ft:f = 94:0.1:101t = 0:1000 > 或类似的值,并且您想要求和的值是您应该能够使用的 abs(tfr)

[fg, tg] = meshgrid(f,t)
is_inside = inpolygon(fg,tg, S(1).x, S(1).y)
integral = sum(abs(tfr(is_inside))

对于 S 中的其他条目也是如此。请参阅 inpolygon 的帮助了解更多示例。您可以使用 ~is_inside 作为曲线外部的点

关于matlab - 等值线图水平值的总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50172942/

相关文章:

Python:二进制二维数组中的轮廓

python - OpenCV Python : cv2. findContours - ValueError:解包的值太多

matlab - 如何创建比较两个矩阵的误差函数?

matlab - 如何找到矩阵中非零行的索引?

linux - Matlab 中的 AlphaData 替代方案

r - 如何在 R 中保存绘图图像?

matlab - 使用幅度向量在极坐标中创建绘图

r - 使用 ggplot2 绘制 R 中数据的逐年相关性散点图

r - ggplot2 facet_wrap 的文本标签

image-processing - 如何绘制标签矩阵中对象的轮廓