Bug 312213 - Scaling from very high to very low resolution produces bad quality image.
Summary: Scaling from very high to very low resolution produces bad quality image.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools/Transform (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-26 08:53 UTC by Tyson Tan
Modified: 2013-01-21 10:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Bad quality resized image. (2.48 KB, image/png)
2012-12-26 08:59 UTC, Tyson Tan
Details
Work around version (2.62 KB, image/png)
2012-12-26 09:01 UTC, Tyson Tan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tyson Tan 2012-12-26 08:53:38 UTC
When downsizing a picture of very high to very small resolution, the outcome quality become very bad. Confirmed in Krita 2.6 RC2, previous version not tested.

In my case, the original image was 1792px square, I was trying to resize it to 32px square, they have an integral ratio number. However, downscaling directly from 1792px to 32px produces a very bad image; while 1792px to 48px seems just fine. I also tried non-integral ratio, from 1752x1751 to 32x32, the outcome was the same. I will attach the images I used and produced.

Workaround: First downscale from 1792px to 256px, then from 256px to 32px. This method produces nice image.

Reproducible: Always

Steps to Reproduce:
1. High resolution original image (1750px square+)
2. Krita menu > Image > Scale to new size
3. Resize it to 32px quare.
4. Notice the "pixelized" quality. 
Actual Results:  
Bad resized image quality under certain circumstances. 

Expected Results:  
The downscaling quality should be consistant regardless to the before-after resolution.
Comment 1 Tyson Tan 2012-12-26 08:58:27 UTC
The original image in this case (too big, so I used URL):
http://www.extvia.com/temp/mascot_20121225_krita.png
Well...this is my design idea for Krita's icon and mascot too. ;)
Comment 2 Tyson Tan 2012-12-26 08:59:57 UTC
Created attachment 76017 [details]
Bad quality resized image.

This is the bad quality resized image, which was scaled from 1792px to 32px directly.
Comment 3 Tyson Tan 2012-12-26 09:01:03 UTC
Created attachment 76018 [details]
Work around version

This is the better version of resized image, which was first scaled from 1792px to 256px and then to 32px.
Comment 4 Halla Rempt 2012-12-26 09:06:57 UTC
I'm not sure this is actually a bug; it's just the way downsampling works. The downscaling in steps is something I've heard people do with other software as well. We've long wanted to make this automatic, though, but never had time to actually implement that.
Comment 5 Tyson Tan 2012-12-26 09:16:33 UTC
Thanks for the reply. I think I can guess some of the mathematical reason behind this. However, can you tell me under what circumstances will the downsampling be nicely conducted, and under what circumstances will not?
Comment 6 Halla Rempt 2012-12-26 09:47:19 UTC
Well, I think it's the case that downsampling breaks down if the step is 
bigger than 50%. I would need to look up my notes from back then -- it 
could be 25%, too.

On Wed, 26 Dec 2012, Tyson Tan wrote:

> https://bugs.kde.org/show_bug.cgi?id=312213
>
> --- Comment #5 from Tyson Tan <extvia@gmail.com> ---
> Thanks for the reply. I think I can guess some of the mathematical reason
> behind this. However, can you tell me under what circumstances will the
> downsampling be nicely conducted, and under what circumstances will not?
>
> -- 
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are watching the assignee of the bug.
>
Comment 7 Dmitry Kazakov 2013-01-05 16:11:09 UTC
Hi!

Could you check with Krita master? I've just pushed a patch that fixes several maths problems in the scaling code, and the result is much better now (in comparison with the attached image at least).

Btw, I've re-enabled Lanczos3 interpolation filter as well. You can try to use it to get better quality.
Comment 8 Tyson Tan 2013-01-06 00:52:52 UTC
Thank you very much for the fixes! Even though I haven't try yet, sinc resampling should be able deliever much better quality. I'll report back when I figure out how to build from Krita master (Currently, I'm using 2.6 RC2 from Kubuntu-beta PPA).
:)
Comment 9 Tyson Tan 2013-01-21 08:20:13 UTC
Today I tried the Krita 2.7 Pre-alpha from Project Neon PPA, the problem did not occur and the result is very impressive. Thank you for looking into this issue!
^^