フィルターのクリア

Locate coordinates of black areas in image.

1 回表示 (過去 30 日間)
jg
jg 2020 年 4 月 16 日
コメント済み: Ameer Hamza 2020 年 4 月 16 日
I have been using the function below to try and find circles but for very warped images i am unable to find circles, is there an alternative to infindcircles() which would return the coordiantes of the black sections of the image?
[centers, radii, metric] = imfindcircles(img,[20 50],'ObjectPolarity','dark');

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 16 日
編集済み: Ameer Hamza 2020 年 4 月 16 日
Try this.
im = im2double(imread('image.jpeg'));
% filter the black circles from colored image
im_gray = rgb2gray(im);
mask = im_gray < 0.1;
% detect and filter the connected regions
reg = bwconncomp(mask);
pxlList = reg.PixelIdxList;
idx = cellfun(@(x) numel(x) > 1, pxlList);
pxlList(~idx) = [];
% calculate the centres of the connected regions
centres = zeros(numel(pxlList), 2);
for i=1:numel(pxlList)
[r,c] = ind2sub(size(im_gray), pxlList{i});
centres(i,:) = mean([r c]);
end
imshow(im);
hold on;
plot(centres(:,2), centres(:,1), 'r+', 'LineWidth', 4, 'MarkerSize', 10)
  2 件のコメント
jg
jg 2020 年 4 月 16 日
Thank you!
Ameer Hamza
Ameer Hamza 2020 年 4 月 16 日
Glad to be of help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by