Azzera filtri
Azzera filtri

how to detect circles in the provided .bmp image?

3 visualizzazioni (ultimi 30 giorni)
Muhammad Imran
Muhammad Imran il 22 Giu 2021
Risposto: Yazan il 30 Giu 2021
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 Commenti
Joel Lynch
Joel Lynch il 22 Giu 2021
can you attach your current script?
Muhammad Imran
Muhammad Imran il 22 Giu 2021
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');

Accedi per commentare.

Risposte (1)

Yazan
Yazan il 30 Giu 2021

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by