I want to calculate the white area of contour
Mostra commenti meno recenti

"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
Risposte (1)
Image Analyst
il 23 Lug 2012
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 Commenti
Image Analyst
il 23 Lug 2012
My code just operates off the image, like the one you are showing. I don't care what format the image was stored it. It might have been JPG, PNG, BMP, TIFF, or whatever. That doesn't matter. All that matters is the image after you've read it in from disk. If you have the x,y coordinates of some contour line(s) then of course you can get the value of the image at those locations.
Image Analyst
il 24 Lug 2012
You can try export_fig - see the first page of the File Exchange. It's always the top download.
Jeong
il 24 Lug 2012
Categorie
Scopri di più su Contour Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!