Respuesta aceptada

darova
darova el 19 de Mayo de 2019

0 votos

If you have only circle on the image like below
img.png
clc,clear
I = imread('img.png');
I1 = im2bw(I,graythresh(I)); % binarize image (0,1)
[row, col] = find(I1); % find white pixels (1 value)
ix = round( mean(col) ); % mean column
iy = round( mean(row) ); % mean row
imshow(I1)
hold on
plot(ix,iy,'or')
text(ix+10,iy+10,'CircleCenter')
hold off

4 comentarios

JoBrr
JoBrr el 20 de Mayo de 2019
Thanks mate, it works, appreciate it a lot. I get a figure window with the image and a circle in the centre.
But do know know how I may display this info in the command window when the script is executed.
Also is the value of the centre in pixels? @darova
darova
darova el 20 de Mayo de 2019
You can use disp() or:
% \n - next line (break line)
% %i - insert integer value
sprintf('center coordinates of a circle:\nrow = %i; column = %i;', iy, ix)
And Yes, values are in pixels
JoBrr
JoBrr el 21 de Mayo de 2019
Thank you @darova much appreciated!!
darova
darova el 21 de Mayo de 2019

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 19 de Mayo de 2019

Editada:

el 29 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by