pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Some artifacts on rendered images

Open LogWell opened this issue 2 years ago • 6 comments

Example from: https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/render_textured_meshes.ipynb

I change the camera to: cameras = OrthographicCameras(R=R, T=T, device=device) and replace azim from 180 to 0 in R, T = look_at_view_transform(2.7, 0, 180) , and add code to export the image:

import cv2
import numpy as np

img_c = images[0].cpu().numpy()
img_c = img_c[..., :3]
img_c = img_c[..., ::-1]
img_c = (img_c * 255).astype(np.uint8)

cv2.imwrite(obj_filename[:-4] + "_c.png", img_c)

Here is the result: cow_c

Some artifacts on the image: image

LogWell avatar Dec 11 '22 16:12 LogWell

This is because a few pixels in the middle of face is assigned to other faces. This seems to originate from MeshRasterizer when using OrthographicCameras or FoVOrthographicCameras. Below figures are visualization of fragment.pix_to_face which is output value from MeshRasterizer.

image image

When converted from OrthographicCameras into FoVPerspectiveCameras, these artifacts disappear. image

jk4011 avatar Jul 03 '23 07:07 jk4011

I'm not very familiar with this part, I just encountered this phenomenon when using it, and I still don't know how to improve this problem...

LogWell avatar Jul 03 '23 08:07 LogWell

The problem is in either OrthographicCameras or MeshRasterizer. Since MeshRasterizer is mainly written in cuda, I hope the bug is in OrthographicCameras.

Just using perspective camera may be good solution though haha.

jk4011 avatar Jul 03 '23 10:07 jk4011

Since I need orthographic cameras, I'm going to dig into this problem within 2 weeks. I really hope the bug is just in OrthographicCameras.

jk4011 avatar Jul 03 '23 10:07 jk4011

I am looking forward to hearing good news from you.

LogWell avatar Jul 03 '23 11:07 LogWell

Does this go away if you set bin_size=0 in the RasterizationSettings?

bottler avatar Jul 04 '23 10:07 bottler