Presenting set of (x, y, z) points as image
17 views (last 30 days)
Show older comments
Itzhak Mamistvalov
on 30 Apr 2021
Commented: Image Analyst
on 7 Oct 2022
Hey everyone,
Im trying to figure out how to solve a problem in an academic project im working on.
I have a set of datapoints with (x, y, z) values. The values represent cordinates on a scanned wall. I retrieve the points by scanning a wall with LIDAR, and getting (x, y, z) arrays, with different precision in each axis. The points are in double format. Note that the z axis is actually the depth of the wall on that (x, y) point.
Now, im presenting the data in a scatter3 plot. Is there a way to present it by an image?
I thought of an idea of creating a matrix of (max(y)-min(y), max(x)-min(x)) and fill it with z values. Note that x, y, z arrays are same length.
How can I create such an image?
Is there a way in which I can fill the missing points with interpolation or something similar maybe?
attaching my code and my scatter3 plot.
%
clear all; close all; clc;
fileID = fopen('d.dat', 'r');
data = fscanf(fileID, "%f %f %f", [3 inf]);
fclose(fileID);
data = data';
Dist = 625;
for i=1:length(data)
x(i)=Dist*tand(data(i,2));
y(i)=Dist*tand(data(i,1));
z(i)=data(i,3)*cosd(data(i,1))*cosd(data(i,2));
end
scatter3(x,y,z,5,z)
colorbar('eastoutside')
view(2)
2 Comments
Image Analyst
on 7 Oct 2022
@tejashree, see attached demo that makes a list of x,y,r,g,b values into a csv text file. Works for gray scale too.
Accepted Answer
Image Analyst
on 30 Apr 2021
Edited: Image Analyst
on 30 Apr 2021
Try surf() or reshape then into image and call imshow()
columns = 1000; % Whatever you want the image size to be
rows = 1000; % Whatever you want the image size to be
ry = rescale(y, 1, columns);
rx = rescale(x, 1, columns);
grayImage = zeros(rows, columns);
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
grayImage(row, col) = z(k);
end
imshow(grayImage, []);
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!