make a box around a circle
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mihael Rakic
am 27 Dez. 2017
Beantwortet: Mihael Rakic
am 28 Dez. 2017
Hi, I have a code that detects a circle in the picture, but what I wan't is to make a rectangle that surrounds the circle. The code that I use is:
if true
function output_image = findCircels(Gevoeligheid,lijn,StraalMin,StraalMax)
output_image = lijn;
coder.extrinsic('imfindcircles');
[centers,radii] = imfindcircles(lijn,[StraalMin, StraalMax], 'ObjectPolarity','dark', 'Sensitivity',Gevoeligheid,'Method','twostage');
lijn = insertShape(lijn,'Circle',[centers radii],'LineWidth',5);
output_image=lijn;
end
Does anyone know how I can make this box around the circle and retract the coordinates of the edges of the rectangle?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 27 Dez. 2017
Use the rectangle() function?
5 Kommentare
Image Analyst
am 27 Dez. 2017
So I guess the answer is "No, I did not look at the documentation for rectangle to see how they created a circle, and I did not pass anything in for curvature." So . . . why not? Here is the link to the documentation:
and here is the example:
pos = [2 4 2 2];
rectangle('Position',pos,'Curvature',[1 1])
axis equal
Also note that the Position variable is [xLeft, yTop, xWidth, yHeight], not the coordinates of the 4 corners or whatever you had.
You might need to call hold on to prevent the rectangle from blowing away any image or data already in your axes.
Also, state whether you want the circle burned into an image or if you just want it to be put into the overlay (like the rectangle function does).
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!