Hi to all, I'am trying to detect circle in this image using this:
[centerPoints, radius] = imfindcircles(newImage ,[2 30],'ObjectPolarity','dark','Sensitivity',0.98);
As you can see I'am in a very high Sensitivity looking for circles in this image but it won't find my circle in Wheat Color just the one in back with black line.
Also I have tried with some color enhancement but it won't work.

 채택된 답변

John BG
John BG 2017년 1월 17일

1 개 추천

Hello Kika
I found a way to spot the inner circle:
1.
capture
A=imread('im1.jpg');
figure(1);h1=imshow(A);
2.
running the cursor around the picture one realises the circle you are after is slightly 'yellow'.
a saturated yellow would be: Yellow = Red + Green [1 1 0]
but this is a rather mild yellow, meaning that the red and green layers of the image are only between 15 and 35 points above the blue layer across the points of interest.
Let's catch these slightly yellow pixels:
A13=A(:,:,1)-A(:,:,3);A23=A(:,:,2)-A(:,:,3);
[x13,y13]=find(A13>30);
% [x23,y23]=find(A23>20);
% x=intersect(x13,x23);y=intersect(y13,y23);
figure(2);imshow(A)
hold all
figure(2);h1=plot(y13,x13,'y*')
3.
one could go now for the function imfindcircles that automates fitting circles, but instead of start guessing what parameters of this function would be the right ones, I chose to do a it manually, a bit a of exercise cannot harm, can it?
A2=A;
A2(x13,y13,1)=255;A2(x13,y13,2)=255;A2(x13,y13,2)=0;
figure(3);h1=imshow(A2);
4.
the square is fairly centred, so all left is to plot a circle
r=floor(mean([abs(min(x13)-max(x13)) abs(min(y13)-max(y13))])/2);
xc=floor(.5*abs(min(x13)+max(x13)));
yc=floor(.5*abs(min(y13)+max(y13)));
figure(1);plot(yc,xc,'g*')
da=1;a=[0:da:360];
px=r*cosd(a)+yc;py=r*sind(a)+xc;
figure(1);plot(px,py,'ro')
dear Kika
either with imfindcircles or shanks mare, the result is the same, you catch the inner circle.
if you find these lines useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
.
additional comment:
1.
it turns out that the mildly yellow points can only be spotted with the variance of the RGB layers
figure(4);varA=surf(var(double(A),0,3));
.
use the Rotate 3D function in the figure window to move the point of view and appreciate the target circle right on the hill that generates the variance for this picture
.
I tried different variance thresholds
vA=varA.CData;
m=255/max(max(vA));
figure(5);imshow(m*vA);
% try var threshold at 500
[x500,y500]=find(vA>500);
hold all;
figure(1);plot(x500,y500,'r*')
% try var threshold at 400
[x400,y400]=find(vA>400);
hold all;
figure(6);plot(x400,y400,'b*')
but the above lines give a better result

댓글 수: 3

shivu shetty
shivu shetty 2018년 4월 5일
hello how can i count no of circles for this image?
John BG
John BG 2018년 4월 8일
Sure, please post it on another question, ok?
Let me the link to the new question, either by email or make a note here.
John BG
John BG 2018년 4월 8일
I have almost completed the solution for the tree rings counting.
If you post a new question with the tree trunk cross section and let me know the link I will post my answer as soon as you let me know.
Regards
John BG

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2017년 1월 16일

1 개 추천

You already asked this and John and I answered and you accepted John's answer. Did it not work? Or not work for this particular color?
How many circles do you want from the image? I can see 1, 2, or 3 depending on how you define a circle. The gray ring consists of two circles, an inner one and an outer one, though they're not complete.
You haven't given the context for what you're doing. Why do you need to find circles? For example if you're looking at a 96 well plate, then simply put your plate into a jig/bracket, snap a picture of it and have a template to look in the same locations all the time. Why bother finding them if they don't move around? Just use a template/mask. For example you could take a blank shot, determine colors in the circles of the template, then take a sample image with stuff in there and compute Delta E to see how much it changed.

댓글 수: 6

Adem Kikaj
Adem Kikaj 2017년 1월 16일
This is a variable environment, I'm working on Nine Men's Morris game so this is a white piece and I want to know if there is a circle or not I have tried to do something with image subtract knowing the basic circle but because of ambient light and shadows sometimes my algorithm response like somewhere happen a move, now I've changed the idea of algorithm I want exactly to find two circles in a Image. Another thing that I'm trying to reach is to play with every kind of piece let's say white, black, blue, red so the ID of piece is not the color because is variable the ID of piece I can say is the shape and the Radius of it.
Image Analyst
Image Analyst 2017년 1월 16일
So pieces are identified by their shape and radius, not their color? What possible shapes can the pieces have?
But it seems like you found the game piece already and croppied it out, so what more do you need? I don't think you need diameter and centroid to subpixel accuracy, or even at all, to just determine if the player put down a piece there.
Even with shadows and lighting differences, you can find the pieces with color segmentation in combination with other methods like shape detection. It could be that a simple one line algorithm like a call to imfindcircles() is just not good enough and you'll need to develop a more sophisticated algorithm.
John BG
John BG 2017년 1월 17일
Kika
In the context of this public forum, it's strongly recommended not to reveal work details that you may be bound not to disclose by work contract confidentiality clause.
there are various reasons why not to, the obvious one:
1.
you may have signed a legally binding contract telling you will not
2.
your employer doesn't want you to
3.
there are people who may want to copy what you do to their advantage. You don't work for them but for your employer.
Kika
is there any other question you would like to solve?
regards
John BG
John BG
John BG 2017년 1월 17일
to IA: the function imfindcirlces would improve with an additional field allowing to direct the circles search to specific figures or axis handles, don't you agree?
John BG
Jan
Jan 2017년 1월 17일
@John BG: A figure or axes handle would not be useful, because both can contain multiple images. Therefore an image handle could be an option instead of providing the image data directly.
I do not see the reason for your "strongly recommended not to reveal work details" comment. What is the connection to this thread?
Image Analyst
Image Analyst 2017년 1월 17일
Now that we know the larger context of him trying to use computer vision to determine disc placement on a Nine Men's Morris playing board, I don't know how knowing the centroid of a playing piece is relevant. Like I've said before, just use a template and determine presence or absence of a playing piece. For example if you wanted to determine occupancy of stadium seats, would you try to determine the hair color and sex of the person occupying a seat? No, it doesn't matter - all that matters is that a seat is occupied. If you had a parking vacancy program and were looking at parking spaces, do you care if the space holds a Ford or a Honda? No, it doesn't matter so don't spend time trying to figure it out. All that matters is if a space is taken or not.

댓글을 달려면 로그인하십시오.

Laura Achola
Laura Achola 2022년 9월 19일

0 개 추천

Try [centerPoints, radius] = imfindcircles(newImage ,[2 30],'ObjectPolarity','bright','Sensitivity',0.98);
I think the issue is that you are using the foreground as dark instead of bright. You won't need the high sensitivity in that case.

카테고리

도움말 센터File Exchange에서 Just for fun에 대해 자세히 알아보기

질문:

2017년 1월 16일

답변:

2022년 9월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by