1

(Example) Point cloud data

Consider a matrix N x 36, where N is the number of points in the point cloud data (3D object) and 36 columns represent the features extracted of which the last 3 columns are (x, y, z) coordinate values of every point.

Now I wish to perform feature analysis in this regard I would like to know how to plot/represent/describe each feature from f1,f2,...f33 over the (x,y,z) coordinates for which they were computed? (to understand the behavior of features)

Is this possible? How? If not, what is the alternative?

Eg: find 2 features file bunny_example with NX5 where N is number of points, 1st and 2nd columns are features 1f1, f21 and 3rd to 5th columns are (x,y,z) coordinate values.

stephen
  • 11
  • 4
  • Maybe you should check http://www.mathworks.com/help/matlab/ref/scatter3.html (ploting point cloud) and http://www.mathworks.com/help/matlab/matlab_prog/loop-control-statements.html (loop control) – RCaetano Aug 30 '16 at 15:55
  • Can you specify how scatter plot and looping can be adopted for my above question. State with an example. – stephen Aug 31 '16 at 10:34
  • In http://www.mathworks.com/help/matlab/ref/scatter3.html#btr5_il-1 example you can see 3 spheres with diferent colours. My suggestion: instead of having the sphere point data you have your points location and according to each of your features (loop across columns 1 to 33) you can create a colormap based on your available values in that feature. Ex: `mat=[1,10,20,...,10,10,10;25,35,45,...,1,1,1;7,10,5,...,20,30,40]` in the plot you would have at 10,10,10 a black dot (min) and at 20,30,40 a gray one and at 1,1,1 a lighter one (max) if you mapped the color scale between you max and min values. – RCaetano Aug 31 '16 at 14:13
  • Can you share the psedu-code of how this can be achieved. Its not clear. – stephen Sep 02 '16 at 09:53
  • 1. For each feature = 1 to 33; 2. Create colormap based on maximum and minimum values of current feature; 3. Apply scatter3 for all points using the respective colormap: `scatter3(MAT(:,34), MAT(:,35), MAT(:,36), S, C)` where `MAT` is the Nx36 matrix and `C` is the colormap. Did I make it more clear to you? – RCaetano Sep 02 '16 at 10:09
  • Lets say I find maximum using `max((MAT(:,m)))` where `m` is current feature, similarly minimum. Now, how to create colormap `C`? – stephen Sep 02 '16 at 10:39
  • Maybe this question can help you http://stackoverflow.com/questions/24630132/matlab-custom-colormap-with-only-3-colors Since you have the maximum and the minimum values you can define your own color map (by creating an array with the desired colors) and then assign to your `scatter3` – RCaetano Sep 02 '16 at 13:30
  • I did try, but since the coordinates are negative as well, there seems to be that scatter3 plot isn't providing me a better solution...you can comment/provide suggestions w.r.t. color maps. – stephen Sep 03 '16 at 15:07
  • Hi RCaetano - can you comment on my answer – stephen Sep 06 '16 at 09:11
  • Hi stephen! I did not make any comments to your previous post since I started to have some doubts about what you really want to plot. Also, after you posted the answer I became a little bit confused if it is already working as you would like or if there is something missing. What I understood so far: you have it working but only with 2 colors instead of having a gradient between them. So, you would like to have a gradient along all the points according to their feature values; am I right or is another thing? – RCaetano Sep 06 '16 at 09:20
  • Hi RCaetano! I want to plot each feature of the object, to analyse which features are really doing good/need to consider. As I did not get how to create a colormap based on features on coordinates as suggested by you. I started taking +ve and -ve values of features and defined two colors which I am not sure about, hope you can suggest proper procedure. I thought would gradient be better to analyse and implemented it, but wanted your suggestion what is right approach? Sorry to disturb. – stephen Sep 06 '16 at 11:02
  • No problem, you are not disturbing anyone ;) I suggest you to edit your question and add the code you developed to it and then remove the answer; this is just to be more clear and organized what you need. I will post an answer with some code that may help you. – RCaetano Sep 06 '16 at 13:07
  • Sample data first 10 rows and 6 (features) columns: `2.0684e-05 7.5750e-06 3.8389e-05 1.0346e-05 -8.3302e-06` `0.0002 -1.7019e-05 -0.0002 -3.8879e-05 8.1841e-05` `-2.3888e-05 -3.5798e-05 2.0476e-05 -4.7382e-05 3.8213e-05` `7.7594e-06 2.9854e-06 3.0756e-05 -1.9135e-06 1.3463e-05` `3.4250e-05 5.6627e-06 7.3759e-06 -8.1303e-05 -1.5577e-05` `4.7731e-06 4.9014e-06 2.5750e-05 2.3827e-06 6.2936e-06` `2.4317e-05 0.0007 3.1783e-05 0.0001 -0.0001` `2.6632e-05 0.0009 0.0001 0.0001 -0.0005` `-1.9714e-05 -1.2456e-06 5.5657e-06 1.8092e-05 1.3787e-05` – stephen Sep 06 '16 at 13:54
  • And Sample (x,y,z) coordinates for the above 6 features: (9x3) `-0.6011 -0.9712 0.3268` `-0.5721 -0.9712 0.3379` `-0.5721 -0.9854 0.32794` `-0.5817 -0.948 0.3298` `0.0708 -0.583 -0.2528` `-0.5721 -0.9429 0.32794` `-0.312 -0.9940 0.4074` `-0.286 -0.994 0.4174` `-0.0864 0.4534 -0.7729` – stephen Sep 06 '16 at 14:00
  • Did my answer help you or do you need more help? – RCaetano Sep 08 '16 at 14:23
  • Thank you RCaetano. I will check and get back to you. – stephen Sep 08 '16 at 14:28
  • New code! See if it helps you Stephen. If you need help to understand the logaritmic color mapping just ask ;) – RCaetano Sep 14 '16 at 18:06
  • Thanks @RCaetano! Will check and get back to you. – stephen Sep 15 '16 at 13:08
  • On HKS features when I tested it fairly works good. But when tested on my features there is always a constant color for every feature. Is it because of very small values between [-1 1] interval (like `e-4` or `e-10` or `e-18` etc) as you suggested earlier. How to overcome this, do we need to go for logarithmic approach? – stephen Sep 16 '16 at 08:39
  • My answer has the logaritmic approach that I sugested previously, and my suggestion was based on the range of values you had. If the values are all of them in the same order (e.g. `e-4`) then you should use a linear scale; however if that is not the case you should go for a logaritmic scale, as I did. If you need to choose sometimes the linear and others the logaritmic you can add na `IF` where `c_data(p, hsv_comp)` is computed. `IF f_max/f_min < thres THEN %linear formula ELSE %logaritmic formula END IF;`, where `thres` is the order of your values, like 1000 or 0.01 for example. – RCaetano Sep 16 '16 at 13:11
  • Can you explain the logarithmic color mapping? – stephen Sep 16 '16 at 13:59
  • Hi RCaetano! I find no change in display even after implementing `if f_max/f_min then linear else log end-if`. – stephen Sep 17 '16 at 12:06
  • Hi RCaetano! Can you explain the logarithmic color mapping? – stephen Sep 20 '16 at 07:11
  • In the following image you can see a colormapping with the scale being defined in steps, linear and logarithmic: http://i.imgur.com/DSoASdA.png As you can see the logarithmic is "slower" at smaller values and then "faster" at higher ones. The bars on the image are scaled to have the same height, however in the code I gave you the step and linear red color should be around the height of the dark blue color in the logarithmic scale (due to the difference of "order" of the values). For even more info about logarithmic scale: https://en.wikipedia.org/wiki/Logarithm – RCaetano Sep 21 '16 at 12:01
  • I feel this doesn't seem to be the right approach to solve the problem. Looking into what I was working, is there a way to analyse the features on coordinate system? Which is the important question. – stephen Sep 22 '16 at 05:06
  • I do not know another way to do what you are asking for. Maybe you should research a little bit more or at least edit your question and provide some code or output examples in order to other users can help you better. I am just wondering how in a first moment you said that the answer I provided worked fine and then it does not work anymore as you expected... – RCaetano Sep 22 '16 at 13:01
  • Hi RCaetano! Your code is fine, but there is constant behaviour in every feature which I did specify earlier as well. Even after doing all the changes suggested by you and researching there seems to be no change. That's where I was thinking is this right approach .... Anyway I still will try exploring and try to comeout with a solution. Meanwhile if you or anyone comes out with hope ... let me know. – stephen Sep 23 '16 at 05:22
  • I do not know if I am right or not about this approach; this is the only way I know to (maybe) solve your problem. Just a tip: if you look at this image http://i.imgur.com/Y4B2MWJ.png (your data in a excel table with conditional format colouring) you maybe can see that is the data you provided that are responsible for the (in)correct colouring. This color scheme is similar to the linear one. Since you have a great range of values in the same feature is impossible to do not have some extremes (red and blue) and many values in the middle with same colour (green ones). – RCaetano Sep 23 '16 at 07:22
  • Hi RCaetano, is there a way I can upload/mail you the features file to understand whats the issue. – stephen Sep 24 '16 at 05:27
  • Maybe you can upload the file to Dropbox, create a public link to the file and post it in the question (edit) This way I and others can help you ;) – RCaetano Sep 25 '16 at 12:57
  • Here is the 2 features file [link] (https://drive.google.com/open?id=0B0DqvFP3xKRFUmxsWmRLZHctaXM) with `NX5` where `N` is number of points, `1st` and `2nd` column are features `f1, f2` and `3rd` to `5th` columns are `(x,y,z)` coordinate values. I hope this will help in understanding what the issue seems to be. – stephen Sep 26 '16 at 04:46
  • Hi RCaetano! Did you find time to check the uploaded file. – stephen Sep 29 '16 at 06:30
  • Hi RCaetano, If you get time kindly check. – stephen Oct 07 '16 at 03:26
  • I have analyzed your dataset and I found this: feature 1: `min = -4.8546e+10; max = 2.4647e+09; mean = -7.7100e+06` feature 2: `min = -3.1647e+09; max = 2.3418e+10; mean = 3.2351e+06`. As I tried to said to you before as you can see you have a large range of values. For feature 1 you have values from `-e10` to `+e9` but the mean of those values is only around `-e6`! If you plot your values, e.g. `plot(data(:,1))` maybe you understand what I am saying. Maybe you have to pre-process your data and remove some outliers (peaks) in order to have a better dataset, but I don' know if you need them. – RCaetano Oct 14 '16 at 10:30

1 Answers1

0

This code may help you:

% Provided example data
features = [2.0684e-05 7.5750e-06 3.8389e-05 1.0346e-05 -8.3302e-06;
  0.0002 -1.7019e-05 -0.0002 -3.8879e-05 8.1841e-05;
  -2.3888e-05 -3.5798e-05 2.0476e-05 -4.7382e-05 3.8213e-05;
  7.7594e-06 2.9854e-06 3.0756e-05 -1.9135e-06 1.3463e-05;
  3.4250e-05 5.6627e-06 7.3759e-06 -8.1303e-05 -1.5577e-05;
  4.7731e-06 4.9014e-06 2.5750e-05 2.3827e-06 6.2936e-06;
  2.4317e-05 0.0007 3.1783e-05 0.0001 -0.0001;
  2.6632e-05 0.0009 0.0001 0.0001 -0.0005;
  -1.9714e-05 -1.2456e-06 5.5657e-06 1.8092e-05 1.3787e-05];

points = [-0.6011 -0.9712 0.3268;
  -0.5721 -0.9712 0.3379;
  -0.5721 -0.9854 0.32794;
  -0.5817 -0.948 0.3298;
  0.0708 -0.583 -0.2528;
  -0.5721 -0.9429 0.32794;
  -0.312 -0.9940 0.4074;
  -0.286 -0.994 0.4174;
  -0.0864 0.4534 -0.7729];

% To create the colormap - like heatmap
initial_hsv = [0 1 1]; % red
final_hsv = [2/3 1 1]; % blue
point_size = 10;
max_hsv = max([initial_hsv; final_hsv]);
min_hsv = min([initial_hsv; final_hsv]);
dif_hsv = max_hsv - min_hsv;

% For each feature
for f = 1 : size(features, 2)

  f_max = max(features(:, f));
  f_min = min(features(:, f));
  c_data = zeros(size(points, 1), 3);

  % For each point
  for p = 1 : size(points, 1)
    for hsv_comp = 1:3
      if dif_hsv(hsv_comp) != 0
        % Logaritmic mapping
        c_data(p, hsv_comp) = (1 - ((log(features(p, f)+abs(f_min)+1) - log(f_min+abs(f_min)+1)) / (log(f_max+abs(f_min)+1) - log(f_min+abs(f_min)+1)))) * dif_hsv(hsv_comp) + min_hsv(hsv_comp);
      else
        c_data(p, hsv_comp) = min_hsv(hsv_comp);
      end
    end
  end

  % Converting to HSV
  c_data(:,:) = hsv2rgb(c_data(:,:));

  % Creating a figure for each feature
  str = sprintf('Feature number %d' , f);
  figure
  scatter3(points(:,1), points(:,2), points(:,3), point_size*ones(size(points,1),1), c_data);
  title(str)

end

NOTES:

  1. You can change the values of inital_hsv, final_hsv and point_size according to your needs.
  2. The way the c_data is computed (in this example is used a logaritmic mapping) can also be changed in order to have smother color transitions based on your feature data.
RCaetano
  • 642
  • 1
  • 8
  • 23
  • Hi RCaetano your answer works fine! Thanks for help! However the color is always constant, like red or black due to color setup. This does not give me an understanding (feature pattern analysis??? first question) of how 3D objects feature(`33`) patterns behave. Maybe need to try with the `c_data` be changed to have a smooth color transitions, How can this be done? – stephen Sep 11 '16 at 13:26
  • Hi check the following 3D object plot. Expecting a plot something similar (each feature values increase as the color goes from blue to green and to red) ![Bunny Plot](http://brickisland.net/DDGSpring2016/wp-content/uploads/2016/05/HeatKernelTeaser.jpg). – stephen Sep 11 '16 at 14:27
  • Since some of the feature values are negative do we need to consider absolute values of those ? – stephen Sep 12 '16 at 04:47
  • Hi @Stephen! The color behaviour you describe results from the fact you have many points in different scales like `e-4` or `e-6`. As I said in note 2, `c_data` is computed linearly so it would lead to some gaps if the data are in different scales (that's why only seeing black or red colors). To overcome that you should modify the way `c_data` is computed; if the data will be similar to the one you provided maybe you should change to a logaritmic approach. – RCaetano Sep 12 '16 at 08:29
  • Hi @RCaetano! Yah scales are differing for each feature. Can you suggest how to compute `c_data` like logarithmic approach or some other references for computing similar to [Bunny Plot](http://brickisland.net/DDGSpring2016/wp-content/uploads/2016/05/HeatKernelTeaser.jpg)? – stephen Sep 12 '16 at 08:43
  • To have the effect like the bunny plot you can use HSV color scale instead of RGB, changing only the Hue value according to the feature value and using the maximum value of Saturation and Value (You can go to http://colorizer.org/ to see what I mean). And there is no problem in having negative values; you just have to make sure you are mapping your values correctly, using also the correct scale (linear, logaritmic, etc). Do you understand what I mean? – RCaetano Sep 12 '16 at 08:45
  • The values for each feature what I obtained are after applying normalization scale like MaxAbs [-1 to 1]. But I still am unable to understand the logaritmic colormap that you are specifying, can you elaborate, how to compute. – stephen Sep 12 '16 at 09:06
  • You need to map your values between a minimum value and a maximum value which will represente the minimum and maximum values of Hue in HSV scale. The logaritmic scale is just to do not have color gaps. See this question for logaritmic scale http://stackoverflow.com/questions/19472747/convert-linear-scale-to-logarithmic and this to connvert RGB to HSV http://stackoverflow.com/questions/22084308/conversion-between-rgb-and-hsv-space I can help you with the code but I do not have time right now, sorry :/ I will try to edit the code tomorow! – RCaetano Sep 12 '16 at 09:14
  • Hi RCaetano! No problem I will wait till tomorrow. Stuck with visualizations and plots. Meanwhile will go through the links and try to fill the gaps. – stephen Sep 12 '16 at 09:22
  • ! I am lost unable to find solution. Did you find time to edit. – stephen Sep 13 '16 at 18:03