3D point cloud image to grayscale image 2 (accurate restoration version)

The code of this article has been uploaded to GitHub
. In the previous article, due to factors such as the conversion on the left, the accuracy was lost, and the original point cloud image was not restored. After a day of thinking, I found that the previous method is not particularly desirable. This article will use a new method to restore the original image to the greatest extent. Before that, make a summary of the two methods:
Method 1: Since the point cloud xyz format corresponds to coordinates and is a floating point number, then convert *10 to an int type number. Then use the maximum number of x-axis and y-axis as the image size.
Method 2: In fact, the point cloud image is consistent with the two-dimensional image, and each point is ordered. We only need to count how many numbers appear on the x-axis and y-axis to determine the size of this graph. For example, a point cloud map.

x y z
1.1 1.1 1.2
1.1 2.0 1.3
2.0 2.0 1.3

Can you see it, in fact, the conversion of this point cloud image into a grayscale image is 2*2 pixels. Because the x-axis only has (1.1, 2.0) y (the same goes for the y-axis). So for example, the first coordinate (1.1, 1.1, 1.2) corresponds to (0, 0, 1.2) on the grayscale image. 0 comes from 1.1 is the 0th element of the x-axis.
insert image description here

Just to mention here, the x-axis and y-axis of the previous article are reversed. How many x-axes indicate how many columns there are, and how many y-axes indicate how many rows there are
insert image description here
insert image description here

insert image description here
Note that the way of indexing yx and map is about twice as fast as np.argwhere.

insert image description here
insert image description here
insert image description here
insert image description here

The code of this article has been uploaded to GitHub

Guess you like

Origin blog.csdn.net/rglkt/article/details/121404604