Skip to content
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

Raster resampling happens before map canvas rotation #23602

Open
qgib opened this issue Oct 7, 2016 · 14 comments
Open

Raster resampling happens before map canvas rotation #23602

qgib opened this issue Oct 7, 2016 · 14 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Map and Legend Related to map or legend rendering Rasters Related to general raster layer handling (not specific data formats)

Comments

@qgib
Copy link
Contributor

qgib commented Oct 7, 2016

Author Name: Johannes Kroeger (Johannes Kroeger)
Original Redmine Issue: 15679
Affected QGIS version: 2.16.3
Redmine category:unknown


If you use QGIS' canvas rotation feature and have raster images in your map, they will look much worse than intended.

It seems like the resampling is done before the rotation. The rotation of course leads to different neighborhood relationships between pixels so the quality degrades. Would it be possible to resample after rotating?

Attached is an example of the same area with Nearest Neighbor resampling as well as Average with 0° and 10° rotation applied. As you can see, the image quality in the 10° Average image looks not very good.


@qgib
Copy link
Contributor Author

qgib commented Apr 30, 2017

Author Name: Giovanni Manghi (@gioman)


  • easy_fix was configured as 0
  • regression was configured as 0

@qgib
Copy link
Contributor Author

qgib commented Sep 22, 2017

Author Name: Jürgen Fischer (@jef-n)


  • category_id was configured as Unknown

@qgib
Copy link
Contributor Author

qgib commented Mar 10, 2018

Author Name: Johannes Kroeger (Johannes Kroeger)


This also affects OTF reprojection as shown in this image. I would update the title if I could.


  • 12403 was configured as no resampling on reprojection.png

@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2019

Author Name: Giovanni Manghi (@gioman)


End of life notice: QGIS 2.18 LTR

Source:
http://blog.qgis.org/2019/03/09/end-of-life-notice-qgis-2-18-ltr/

QGIS 3.4 has recently become our new Long Term Release (LTR) version. This is a major step in our history – a long term release version based on the massive updates, library upgrades and improvements that we carried out in the course of the 2.x to 3x upgrade cycle.

We strongly encourage all users who are currently using QGIS 2.18 LTR as their preferred QGIS release to migrate to QGIS 3.4. This new LTR version will receive regular bugfixes for at least one year. It also includes hundreds of new functions, usability improvements, bugfixes, and other goodies. See the relevant changelogs for a good sampling of all the new features that have gone into version 3.4

Most plugins have been either migrated or incorporated into the core QGIS code base.

We strongly discourage the continued use of QGIS 2.18 LTR as it is now officially unsupported, which means we’ll not provide any bug fix releases for it.

You should also note that we intend to close all bug tickets referring to the now obsolete LTR version. Original reporters will receive a notification of the ticket closure and are encouraged to check whether the issue persists in the new LTR, in which case they should reopen the ticket.

If you would like to better understand the QGIS release roadmap, check out our roadmap page! It outlines the schedule for upcoming releases and will help you plan your deployment of QGIS into an operational environment.

The development of QGIS 3.4 LTR has been made possible by the work of hundreds of volunteers, by the investments of companies, professionals, and administrations, and by continuous donations and financial support from many of you. We sincerely thank you all and encourage you to collaborate and support the project even more, for the long term improvement and sustainability of the QGIS project.


  • resolution was changed from to end of life
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Mar 9, 2019
@qgib qgib added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 25, 2019
@kannes
Copy link
Contributor

kannes commented Jul 7, 2019

This is still the case in 3.8, please re-open.

Maybe there is no filtering applied to the map canvas in general after rotation?

@gioman gioman reopened this Jul 8, 2019
@gioman gioman added Rasters Related to general raster layer handling (not specific data formats) Map and Legend Related to map or legend rendering labels Dec 21, 2020
@Pedro-Murteira
Copy link

This is still valid on QGIS 3.22.3.

@AlisterH
Copy link
Contributor

AlisterH commented Jun 27, 2023

Here is another sample showing that this is really bad if people want to bring raster (perhaps scanned) maps to QGIS.
I sometimes "export map to image" to use in CAD (yes, to render the text it has to be very high resolution, but this is better than bringing in vast amounts of vector data to CAD).
If I have the map rotated in QGIS when I export, I get a rotated geotif. For reference, this is what it looks like in an image viewer (which does not know anything about the rotation):
image
If I wanted to load a rotated image like this into QGIS, it would be illegible (regardless of the rotation I set for the QGIS window):
image
image
If I wanted to bring in scanned maps or something with some rotation, I would need to upsample them significantly for legibility.

@elpaso
Copy link
Contributor

elpaso commented Jun 27, 2023

I am afraid there is nothing we can do: the exported image is rotated and GDAL loads it correctly.

You can try different resampling algorithms to get a slightly better image.

immagine

@kannes
Copy link
Contributor

kannes commented Jun 27, 2023

The issue is that this resampling is done before the canvas rotation. The "resampling" of the rotation is not filtered and leads to jarring aliasing.

A reduction in visual quality when rotating rasters is to be expected but it could be drastically reduced if it wasn't a nearest neighbor operation (I guess).

@elpaso
Copy link
Contributor

elpaso commented Jun 27, 2023

The issue is that this resampling is done before the canvas rotation. The "resampling" of the rotation is not filtered and leads to jarring aliasing.

Rotation of the canvas in QGIS is not involved at all in this issue.

After you load a raster which was exported from a rotated image the issue appears also if the canvas is not rotated. It is the original raster which was rotated when exported, GDAL knows that from the world file and applies the appropriate transformation.

@kannes
Copy link
Contributor

kannes commented Jun 27, 2023

Ah, I missed that @AlisterH's comment was only tangentially really related to my bug report. @AlisterH maybe make a feature request to make raster export of a rotated canvas store a resampled image instead of "just" an image with its rotation defined in the metadata (if that is what happens).

@AlisterH
Copy link
Contributor

AlisterH commented Jun 27, 2023

No, I'm not complaining about export of rotated maps, I'm talking about display of rasters with rotated geotransform. I think it is #46262, which has been marked as duplicate of this (although it was also addressed in another old ticket). So maybe that one should be reopened if we want to keep the issues separate?

@alexbruy
Copy link
Contributor

Does activating "Early resampling" checkbox in the recent QGIS versions improves situation?

@AlisterH
Copy link
Contributor

There is almost no improvement in my example of rasters with rotated geotransform.
I don't see any improvement in the case of a rotated canvas and a raster without rotated geotransform - but perhaps there is a minimal improvement and I just can't see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Map and Legend Related to map or legend rendering Rasters Related to general raster layer handling (not specific data formats)
Projects
None yet
Development

No branches or pull requests

7 participants