how to detect black colors
2 次查看(过去 30 天)
显示 更早的评论
How can I detect a lot of black colors and mark bounding boxes from overall gray image?
回答(1 个)
yanqi liu
2022-2-25
yes,sir,may be the view:https://ww2.mathworks.cn/matlabcentral/answers/1656655-how-can-i-detect-black-color-and-mark-bounding-box-from-overall-gray-image
or use the follow code
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/905790/Screenshot_20220224-200026_Samsung%20Notes.jpg');
mask = imdilate(~im2bw(img, 100/255), strel('square', 39));
props = regionprops(mask, 'BoundingBox');
figure; imshow(img, []);
hold on;
for i = 1 : length(props)
rectangle('position', props(i).BoundingBox, 'EdgeColor', 'g', 'LineWidth', 2)
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!