Filter löschen
Filter löschen

How to detect the 6 circles and the center points?

2 Ansichten (letzte 30 Tage)
Husain Signalwala
Husain Signalwala am 10 Nov. 2022
I = imread("myimage.jpg"); %original file
imshow(I)
imhist(I)
I = im2gray(I); %coverting to grayscale
Ia = imadjust(I); %histogram stretching
imshow(Ia)
imhist(Ia)
avg = fspecial("average",[50 50]) %average filtering
Iavg = imfilter(Ia,avg);
If = medfilt2(Iavg,[60 60]); %median filtering
imshow(If)
Ibw = imbinarize(If);
imshow(Ibw)
edges = edge(Ibw);
imshow(edges)
From the original image "myimage.jpg" I want to detect the 6 circles and the center point and center line for those cirlces. I tried basic averaging and median filters to make the image smooth and the curves smooth (images attached). After that I tried using hough transform to detect the circles but it did not give me the results.
Is there any function or method that could solve this issue.
  2 Kommentare
Image Analyst
Image Analyst am 10 Nov. 2022
I don't see 6 circles. I see a big fuzzy asterisk.
Can you annotate an image and show us exactly where the circles are?
Husain Signalwala
Husain Signalwala am 11 Nov. 2022
@Image Analyst I want to locate these lines indicated in the figures and the circles(attached). It is not necessary that the centerlines coincide at one point. Any way I can locate these?
Thanks.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 11 Nov. 2022
Try using radon
However it's a judgment call as to how far out you want to go to define the boundary of the circle.
  4 Kommentare
Husain Signalwala
Husain Signalwala am 11 Nov. 2022
I = imread("myimage.jpg");
imshow(I)
I = im2gray(I);
I = rescale(I);
imshow(I)
I = imadjust(I);
kernel = ones(61);
If = imfilter(double(I),kernel);
imshow(If,[])
BW = edge(If);
imshow(BW)
theta = 0:179;
[R,xp] = radon(BW,theta);
figure
imagesc(theta,xp,R)
colormap("hot")
xlabel("\theta (degrees)")
ylabel("x^{\prime} (pixels from center)")
title("R_{\theta} (x^{\prime})")
colorbar
R_sort = sort(unique(R),"descend");
[row_peak,col_peak] = find(ismember(R,R_sort(1:6)));
xp_peak_offset = xp(row_peak)
theta_peak = theta(col_peak)
This is my code until now.
The theta_peak values are [0 2 90 90 90 90], which I think does not give me the solution. Can you just recheck the code? I have applied edges too before applying radon.
I am just a beginner, sorry if there are any dumb mistakes.
Husain Signalwala
Husain Signalwala am 14 Nov. 2022
@Image Analyst Hello Sir,
By using this code, this is the closest I could come to finding the centerlines. The results are not accurate. From the theta_peak values I had chosen 6 values on assumptions. Can you suggest me something to get a bit more accurate results? Also using radon, all the centerlines meet the centerpoint of the image. This is not true. It is not necessary they all pas through a single point.
I = imread("myimage.jpg");
imshow(I)
I = im2gray(I);
I = rescale(I);
imshow(I)
I = imadjust(I);
BW = edge(I);
imshow(BW)
theta = 0:179;
[R,xp] = radon(BW,theta); %
figure
imagesc(theta,xp,R)
colormap("hot")
xlabel("\theta (degrees)")
ylabel("x^{\prime} (pixels from center)")
title("R_{\theta} (x^{\prime})")
colorbar
R_sort = sort(unique(R),"descend");
[row_peak,col_peak] = find(ismember(R,R_sort(1:12)));
xp_peak_offset = xp(row_peak)
theta_peak = theta(col_peak)
centerX = ceil(size(I,2)/2)
centerY = ceil(size(I,1)/2)
figure
imshow(I)
hold on
scatter(centerX,centerY,50,"bx",LineWidth=2)
axis on
plot(centerX + xp_peak_offset(1,:),tan,"bx",LineWidth=2) %using tan
[x1,y1] = pol2cart(deg2rad(42),600);
plot([centerX-x1 centerX+x1],[centerY+y1 centerY-y1],"r--",LineWidth=2)
plot (961,290,"bx",LineWidth=2)
[x2,y2] = pol2cart(deg2rad(46),500);
plot([centerX-x2 centerX+x2],[centerY+y2 centerY-y2],"r--",LineWidth=2)
[x3,y3] = pol2cart(deg2rad(100),500);
plot([centerX-x3 centerX+x3],[centerY+y3 centerY-y3],"r--",LineWidth=2)
[x4,y4] = pol2cart(deg2rad(106),500);
plot([centerX-x4 centerX+x4],[centerY+y4 centerY-y4],"r--",LineWidth=2)
[x5,y5] = pol2cart(deg2rad(157),500);
plot([centerX-x5 centerX+x5],[centerY+y5 centerY-y5],"r--",LineWidth=2)
[x6,y6] = pol2cart(deg2rad(166),500);
plot([centerX-x6 centerX+x6],[centerY+y6 centerY-y6],"r--",LineWidth=2)
Waiting for your valuable suggestion/inputs.
Thankyou.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by