How to count area under given surface ?

1 次查看(过去 30 天)
Hello,
I want to count areas limited by green lines.
So, for my image the result is three areas.
Can anyone help me please.

采纳的回答

Ameer Hamza
Ameer Hamza 2020-4-30
编辑:Ameer Hamza 2020-4-30
Try this. It gives the area of three regions in number of pixels
im = im2double(imread('area.jpeg'));
im(:,end-5:end,:) = 0; % remove the white line at right and bottom of image
im(end-5:end,:,:) = 0;
mask = (im(:,:,1)>0.75) & (im(:,:,2)>0.75) & (im(:,:,3)>0.75);
regions = bwconncomp(mask);
areas = cellfun(@(x) numel(x), regions.PixelIdxList);
required_areas = maxk(areas, 3);
  4 个评论
MMSAAH
MMSAAH 2020-5-4
I'm using R2016a.
I've changed maxk() by :
[val ind] = sort(areas,'descend');
required_areas=val(1:3);
Now, it works.
Is it possible to transform the number of pixels to cm ?
Ameer Hamza
Ameer Hamza 2020-5-4
You will need to specify the pixel per cm to find out the area.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by