什么距离代表两个相邻的像素

what distance represent two adjacents pixels

我有一个 3d 点云。我使用 matplotlib 绘制了一个散点图,表示从上方观察到的点云。点云存储为以米为单位的坐标列表。 matplotlib.pyplot.scatter 的输出是一个 png 图像。

除了保存图像,我想保存对应的像素<->米。怎么做到的?

这是我用 matplotlib 制作图像的代码。我使用数据框来操作点云。

        colors = np.array((self.cloud["red"], self.cloud["green"], self.cloud["blue"])).T
        dpi = 72
        print("dpi: ",dpi)
        fig = plt.figure(figsize=(18000/dpi, 18000/dpi), dpi=dpi)
        ax = plt.axes(projection='3d')
        ax.view_init(elev=90., azim = 0)
        ax.set_snap(True)
        ax.scatter(
            self.cloud["x"],
            self.cloud["y"],
            self.cloud["z"],
            marker=MarkerStyle('.', fillstyle = 'full'),
            facecolors=colors / 255,
            zdir="z",
            #to set a point to 1 pixel we use the relation (dpi/fig.dpi) but
            #the problem of the point cloud is the fact that we didn't have a point at each pixel so we increase the size of a point 
            #the size is empiric so need to be careful 
            s = (25)**2,
            )
        plt.axis('off')
        self.set_proper_aspect_ratio(ax)
        fig.tight_layout()
        plt.savefig(file_name, orientation = 'portrait', transparent = True, dpi=fig.dpi)

为了找到这个距离,我使用这个代码:

inv = ax.transData.inverted()
#center_image is in pixel
distance_x = abs(inv.transform((center_image[0],center_image[1]))[0])
distance_y = abs(inv.transform((center_image[0],center_image[1]))[1])