I want to calculate the white area of contour

2 次查看(过去 30 天)
"How can I calculate the white area of this contour?"
In my opinion, the number of white pixels corresponds to the white area I think.
If it is right, could you explain that how to count the number of white pixels.
Or do you have any other idea to calculate the area, please let me know.
thank you.
Here is m-file that creates contour.
clear;
clf;
clc;
filename = 'project.txt';
datatable = load(filename);
data = datatable(2:end,2:end);
length = datatable(1,2:end);
time = datatable(2:end,1).';
datasize=size(data);
row=datasize(1,1);
column=datasize(1,2);
row=1:row;
[c,h]=contourf(length,row',data,[20 2 30]);
colormap gray
grid on
hold on

回答(1 个)

Image Analyst
Image Analyst 2012-7-23
I don't have your data file so I can't run your code. But it looks like a gray image with the white being 255 so the usual code for that is
whitePixels = grayImage == 255; % A logical (binary) image
numberOfWhitePixels = sum(whitePixels(:));
  5 个评论
Image Analyst
Image Analyst 2012-7-24
You can try export_fig - see the first page of the File Exchange. It's always the top download.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by