How to Reduce Artifacts from Aliasing After Projective Transformation #1645
-
I have a use case where I'm seeing artifacts in an image after projective transforming it with significant downscaling. I'm transforming this, (This image is public domain): And the result I get is this: At the high level, my intention is to take a flat art image and perspective transform it onto a stock background image to make images like this: https://twitter.com/AppraisalBot/status/1398487427145211904 I've simplified the code I'm using to do this down to this:
The matrix is calculated based on the art images dimensions and the target corners on the background image. The math I'm using can be seen here but I don't expect it to be relevant to this question. I'm using the Spline resampler because it had the best result relative to the other known samplers from my testing. It was also labelled as having "Smooth" output which I think is what I'm looking for. The artifacts are present in artImage before it's drawn onto backgroundImage, so passing GraphicsOptions to x.DrawImage() won't help. Does anyone have any ideas to achieve this sort of perspective transform with downscaling with less visible artifacts? Some sort of different resampler? A parameter I'm missing? Should I downscale first and then perspective transform? Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Performing a perspective transform then scaling via Here's the output of a very rough approximation of your transform |
Beta Was this translation helpful? Give feedback.
Performing a perspective transform then scaling via
Resize
will give you much better quality output.It looks like there's still work to do improving the output quality of our transformsEDIT. I just did a comparison with SkiaSharp and our output is virtually identical.Here's the output of a very rough approximation of your transform