8000 请问您是怎样让生成的网格可视化的? · Issue #8 · 3swu/DocUNet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

请问您是怎样让生成的网格可视化的? #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ARnnn opened this issue Apr 9, 2021 · 7 comments
Open

请问您是怎样让生成的网格可视化的? #8

ARnnn opened this issue Apr 9, 2021 · 7 comments

Comments

@ARnnn
Copy link
ARnnn commented Apr 9, 2021

No description provided.

@3swu
Copy link
Owner
3swu commented Apr 9, 2021

把mesh中每个像素的值归一化再乘255,然后保存为图像就ok

@ARnnn
Copy link
Author
ARnnn commented Apr 9, 2021 via email

@3swu
Copy link
Owner
3swu commented Apr 9, 2021

可视化图是灰色还是彩色可能和您保存为灰度图像或者RGB图像有关,至于第二个问题,我也不能确定什么原因

@ARnnn
Copy link
Author
ARnnn commented Apr 9, 2021 via email

@3swu
Copy link
Owner
3swu commented Apr 14, 2021

尺寸应该不变,每个像素的值范围为0-255吧,这是我可视化的代码,供你参考:

import matplotlib.pyplot as plt
import matplotlib.image as mig
from matplotlib import cm
import numpy as np
import os
import scipy.io as sci

label_path = "/home/wulei/big_dset_crop/labels/3128-0.npz"

filename = label_path.split("/")[-1][0:-4]
save_folder = "label_vis"
if not os.path.exists(save_folder):
    os.mkdir(save_folder)

is_mat = False
if label_path[-4:] == ".npz":
    label = np.load(label_path)
    label_x, label_y = label['x'], label['y']
else:
    is_mat = True
    label = sci.loadmat(label_path)['fm']
    label_x, label_y = label[:,:,0], label[:,:,1]

x_max, x_min, y_max, y_min = np.max(label_x), np.min(label_x), np.max(label_y), np.min(label_y)
print(x_max, y_max)
for i in range(label_x.shape[0]):
    for j in range(label_x.shape[1]):
        if label_x[i][j] < 0:
            label_x[i][j] = 100
        else:
            label_x[i][j] = (label_x[i][j] / x_max) * 255
        
        if label_y[i][j] < 0:
            label_y[i][j] = 100
        else:
            label_y[i][j] = (label_y[i][j] / y_max) * 255


# 彩色
plt.imsave(os.path.join(save_folder, filename + ("-gt" if is_mat else "") + "-x.png"), label_x)
plt.imsave(os.path.join(save_folder, filename + ("-gt" if is_mat else "") + "-y.png"), label_y)

# 灰度
# mig.imsave(os.path.join(save_folder, filename + ("-gt" if is_mat else "") + "-x.png"), np.uint8(label_x), cmap=cm.gray)
# mig.imsave(os.path.join(save_folder, filename + ("-gt" if is_mat else "") + "-y.png"), np.uint8(label_y), cmap=cm.gray)

@zijk
Copy link
zijk commented Apr 25, 2022

那个我能问一下这个代码具体要怎么执行吗?texture_folder那几个路径下放的是什么呀,没有弄的

@zbzzz
Copy link
zbzzz commented Nov 10, 2022

那个我能问一下这个代码具体要怎么执行吗?texture_folder那几个路径下放的是什么呀,没有弄的

您好,请问您解决了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0