Area under the plot
Show older comments
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
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!