Plotting centroid values

Hey Guys,
I find the centroid values in an image using the regionprops command. I am able to plot the centroids on the image as well. Could anyone tell me how I can include the centroid values beside the plot. i.e. if the centroid of my image is at (3,3), i want to plot the centroid and display the value along with it. I am able to do the former and I need help with the latter.
Nancy

 Respuesta aceptada

Paulo Silva
Paulo Silva el 3 de Jul. de 2011

0 votos

4 comentarios

Nancy
Nancy el 3 de Jul. de 2011
Thanks Paulo. But I couldnt find the answer to my problem in this.
Paulo Silva
Paulo Silva el 3 de Jul. de 2011
can you explain better what do you want? 'centroid values besides the plot'
Nancy
Nancy el 3 de Jul. de 2011
Say in a figure, a point G denotes the centroid. I know the value of the centroid to be (3,3). I want this value to be displayed near the point G on my figure.
Paulo Silva
Paulo Silva el 3 de Jul. de 2011
In the link that I posted you have
x = s(k).Centroid(1);
y = s(k).Centroid(2);
text(x, y, sprintf('%d', s(k).ClassNumber), 'Color', 'r', ...
'FontWeight', 'bold');
Instead of that code do
x = s(k).Centroid(1);
y = s(k).Centroid(2);
text(x+d,y,' \leftarrow G','FontSize',18) %where d is the distance from the point
If you want to have many centroids at the same vertical point just define a constant x+d and they will be all aligned

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 3 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by