Area under the plot

5 views (last 30 days)
Divya Kumar
Divya Kumar on 23 Mar 2024
Edited: Matt J on 24 Mar 2024
Hello,
I have an image where I have plotted the boundaries with green color. I want to know the area under the green colored plot. Could someone help me with a matlab code?
I have attached my sample image and the green boundary plotted image with my code too.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
close all;
clc;
I = imread('sample.png');
I_gray = im2gray(I);
I_bin = imbinarize(I_gray);
I_rev = imclearborder(I_bin);
B = bwboundaries(I_rev);
figure()
imshow(I_gray)
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.6)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Accepted Answer

Matt J
Matt J on 24 Mar 2024
Edited: Matt J on 24 Mar 2024
bwarea(I_rev)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!