-2

I have a set of 3D points that creates point cloud. Ii can read and display it in MATLAB with this code

ptCloud1 = pcread('sub2a.ply')
figure
showPointCloud(ptCloud1)

I need to add labels for each point in dense point cloud display. How can I do this?

Dima
  • 38,860
  • 14
  • 75
  • 115
  • 3
    You want to add labels for each point in a dense point cloud? How do you plan to read the labels if the point cloud is dense? Btw, your example is not very useful. Please create an [mcve](http://stackoverflow.com/help/mcve) – kkuilla Sep 28 '15 at 10:34
  • in plot figure there is a application named data cursor when you click it and tap on a point the x,y,z information showed there i need to add point label there too – Babak Ghassemi Sep 28 '15 at 11:48
  • 1
    And how do you expect people to know that unless you are telling them? You haven't explained your problem enough. You are leaving the reader guessing too much. Please create an [mcve](http://stackoverflow.com/help/mcve) and include all relevant information so that others can reproduce your problem and play with it. I know you just want a quick answer but it is worth putting in the effort. You will have a much higher chance of getting a useful answer if you do. – kkuilla Sep 28 '15 at 11:55

1 Answers1

2

You can add text to a plot by using text:

text(x,y,z,str) positions the text in 3-D coordinates.

Thus, since you want the coordinates:

str = sprintf('x:%f, y:%f, z:%f',x,y,z);
text(x,y,z,str)

where you can take a look at the formatting options of sprintf for help on the amount of decimals. Just add this to your figure by using hold on.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • thanks for your help. but i want to show just number of the point not all of the coordinates – Babak Ghassemi Sep 29 '15 at 06:30
  • Then use the same command to show just the text you want. Create a string with `sprintf` then print it on the plot with `text`. Read the linked documentation pages in the answer. – Adriaan Sep 29 '15 at 08:28
  • 1
    @BabakGhassemi. Adriaan showed you the right way to do it. You have to use the `text` function to add labels to your points. The exact final syntax will depend on how exactly you want to label the points (you have to understand how to build strings for that, and `sprintf` is a good way to do it. You can also check how the labels were used in this [answer](http://stackoverflow.com/questions/30078436/matlab-3d-surface-plot/30080366#30080366), there is the number of the point and other information for each label. – Hoki Sep 29 '15 at 11:13
  • @Adriaan thank you this is useful way but unfortunatly I dont know how to acquire index of the each point to add in str – Babak Ghassemi Sep 29 '15 at 12:37
  • 1
    That is a separate question. Please ask a new question for that, again according to [how to ask](http://stackoverflow.com/help/how-to-ask). If this answer did solve the problem as stated in your question, please accept it. This can be done by pressing the check mark below the vote arrows left of the answer. This signifies others that this was the answer that helped you solve this problem, as well as that you no longer require help with this specific question. – Adriaan Sep 29 '15 at 12:43