Color objects with areas larger than a set value
Show older comments

I 1960 images like this. I am trying to identify the regions where the areas have gotten larger than a set value by coloring them in. For example in the fourth Image the bottom cluster of circles would have a large area and that would be colored in. I pasted the code I am trying to implement below. Is there a way to do this using a loop or would a mask be needed first?
video = VideoWriter('Example.avi')
open(video);
for img = 1:1000
file = strcat('bw_frame', num2str(img),'.jpeg');
I = imread(file);
I = imbinarize(I);
[L, n] = bwlabel(I);
stats = regionprops(L, 'Area');
for count = 1:length(n)
val = stats.Area;
if val(count) > 1000
rgb2 = label2rgb(L);
end
end
writeVideo(video,rgb2)
disp(img)
end
close(video);
Accepted Answer
More Answers (0)
Categories
Find more on Modify Image Colors 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!