-
Notifications
You must be signed in to change notification settings - Fork 574
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
Unexpected steps in output of rasterize() #1551
Comments
Oh interesting, |
Out of curiosity I think I tracked down the actual drawing algorithm, it's buried here: |
Also this may be slightly effected by how we convert to pixel coordinates, but adding a
|
After some more testing (sorry for the long delay) I think the behavior described in my initial post is completely explained by the use of But this also just seems to be a result of conversion to pixel coordinates. There are still instances in which the starting point of a drawn edge is in a pixel to the left of the 45° slope and the endpoint in a pixel to the right of it (and vice versa), resulting in a step. I do not think rounding is necessary here. According to the documentation of Pillow the origin of the coordinate system is in the top left corner of the pixel. The image you posted seems to be equivalent to shifting the origin by half a pixel. I think this issue can be closed. If anything this should probably be a feature request for Pillow. |
No worries! Yeah I think this is on pillow, perhaps this issue. Microsoft also has a nice bit on pixel-fill rules that was kind of interesting. |
Hi everyone,
I noticed that images generated by rasterize() do not always look exactly like I would expect them to look. I tried different settings but could never get rid of the issues entirely.
To demonstrate I used an X-shaped mesh (trimesh-test-cross.zip) and the code below.
I scaled the image up by a factor of two to make it easier to see the steps I am talking about.
At first I thought it might just be the pixel grid and the edges of my mesh coinciding by chance. Looking at the image below (pixel grid on top of the edges) however shows that if one edge coincides with the corners of the pixels the other edge should not. The bottom right circle in the image above shows a step in both edges.
Using mesh.projected() changes the result but still shows some steps. The same goes for shifting the origin by half a pixel in one dimension.
The best workaround I have so far is rendering a much higher resolution and then scaling that image down without interpolation. Unfortunately my application requires high accuracy as well as high resolution so this approach might not work for long.
Is there anything else I have overlooked that might be worth a try?
(I am running trimesh 3.10.7 but noticed these issue even before the last update)
The text was updated successfully, but these errors were encountered: