how can I detect black(specific) color in this image
1 回表示 (過去 30 日間)
古いコメントを表示
how can I detect black(specific) color in this image
I want to detect from color and draw a lot of bounding box of a suitable size so that the area is not clipped like image 111
2 件のコメント
回答 (1 件)
yanqi liu
2022 年 3 月 2 日
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/910360/original%20image.jpg');
I = rgb2gray(img);
bw = ~imbinarize(I,'adaptive','ForegroundPolarity','dark','Sensitivity',0.35);
[L,~] = bwlabel(bw);
figure; imshow(img, []); hold on;
h = imshow(label2rgb(L));
set(h, 'AlphaData', 0.5);
bw2 = imclose(bw, strel('disk', 5));
bw2 = bwareaopen(bw2, 20);
[L2,~] = bwlabel(bw2);
stats = regionprops(L2);
hold on;
for i = 1 : length(stats)
hold on; rectangle('position', stats(i).BoundingBox, 'EdgeColor', 'g', 'LineWidth', 2)
end
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!