gpt4 book ai didi

matlab - 如何使用 MATLAB 计算图像中曲线下的面积?

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:47 24 4
gpt4 key购买 nike

alt text http://internationalpropertiesregistry.com/Server/showFile.php?file=%2FUpload%2Fstatistics.gifc49ca28823a561a41d09ef9adbb5e0c5.gif

x轴的单位是小时(h),一共是24小时。

y轴的单位是百万(m)。

如何以 m*h 为单位计算图像中红色曲线下的面积?

重要更新

只有图像(不是数据)可用,我想以编程方式计算面积。

最佳答案

这是一个有趣的解决方案 :)。顺便说一句,它使用需要一些用户交互的 bwfill(类似于 imfill)。

代码

%# Constants
gray_value_curve = 2;
gray_value_box = 3;
area_box_in_units = 10;

%# Read the image
I = imread('C:\p23\graph.gif');
%# Find the area of a unit block
figure(1);
imshow(I,[]);
[BS sq_elem] = bwfill;
imshow(BS,[]);
%# Get the dimensions to make the estimate more accurate
X = zeros(size(BS));
X(sq_elem) = 1;
s = regionprops(X,'Area','BoundingBox');
block_area = s.Area + 2*(s.BoundingBox(3)-1) + 2*(s.BoundingBox(4)-1) + 4;

%#Find the area under the curve
I( ~(I == gray_value_curve | I == gray_value_box) ) = 0;
figure(2);
imshow(I,[]);
[BA area_curve_elem] = bwfill;
imshow(BA,[]);
%# Area under the curve
curve_area = numel(area_curve_elem);

%# Display the area in the required units
area = area_box_in_units*curve_area/block_area;
disp(area);

输出

113.5259

图 1 alt text图 2 alt text

关于matlab - 如何使用 MATLAB 计算图像中曲线下的面积?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2973973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com