フィルターのクリア

how to detect circles in the provided .bmp image?

3 ビュー (過去 30 日間)
Muhammad Imran
Muhammad Imran 2021 年 6 月 22 日
回答済み: Yazan 2021 年 6 月 30 日
i am trying to detect all the possible circles in an image. I did some prprocessing to enhance the image an reduce the the noise. first of all I converted it into grayscale then did some contrast stretching and then apply median filter to remove noise. but after that i used region prop to get the area and diameter of the circles it shows just one big area and its diameter I also checked it in image region analyzer. but i want to know area and diameter of all the circles so i can place circles on that area. anyone can help me?? i have also attached the image
  2 件のコメント
Joel Lynch
Joel Lynch 2021 年 6 月 22 日
can you attach your current script?
Muhammad Imran
Muhammad Imran 2021 年 6 月 22 日
here is the code....
%% contrast stretching
clc
clear all;
close all;
img = rgb2gray(imread('10.bmp'));
subplot(2,2,1); imshow(img); title('Origional Image');
% d = imdistline;
% figure(1); imshow(img);
w1 = 50;
w2 = 150;
r1 = 70;
r2 = 130;
L = 255;
a = w1/r1;
b = (w2-w1)/(r2-r1);
g = (L-w2)/(L-r2);
[x y z] = size(img);
for i=1:x
for j=1:y
if img(i,j)<=r1
r=img(i,j);
elseif img(i,j)>=r1 && img(i,j)<=r2
r=img(i,j);
img(i,j)= (b*(r-r1))+w1;
else
r = img(i,j);
img(i,j)= (g*(r-r2))+w2;
end
end
end
subplot(2,2,2); imshow(img); title('Enhanced Image');
% kaverage = filter2(fspecial('average',3),img)/255;
kmedian = medfilt2(img,[20 20]);
subplot(2,2,3); imshow(kmedian); title('filtered image');
im = im2bw(kmedian);
subplot(2,2,4); imshow(im); title('Binary Image');
prop = regionprops(im, 'EquivDiameter');
allDiameters = [prop.EquivDiameter];
% im = imfill(im, 'holes');
% % subplot(2,2,4);
% figure; imshow(im); title('Filled Binary Image');

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

回答 (1 件)

Yazan
Yazan 2021 年 6 月 30 日

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by