필터 지우기
필터 지우기

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 CenterFile Exchange에서 Read, 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