Is someone know which alogirhtm(s) Microsoft used in Paint to downscale picture?
I'm trying to develop a little software (for personnal use) to downscale a lot of pictures (in Java). After using the "builtin" java functions as NearestNeighbor, Bilinear and Bicubic, with poor result quality... I've used Lanczos algorithm which give far better results but without reaching MS Paint results :/
Note: Paint version used is the one of Windows 7, the Lanczos implementation I've used is the one of the Millie project LanczosResamplePlugin.java and the builtins java are from Graphics2D :
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
If someone have an idea to reach the same quality result, it will be helpfull (for my resulting pictures, and also for my knowledges).
Some results here:
(I'm not posting NN, bilinear and bicubic results which give really poor quality results)
Bellow a landscape (found on google image). Original file size is 1680x1050, and the grass is really sharpen in original file (so Paint result seems to be better than Lanczos).
Original image can be view here : landscape-wallpaper-11a.jpg
Lanczos result:
vs Paint Result:
Another picture bellow (personnal picture), with some text. You can notice that in Lanczos result the text is less readable (less sharpen) than in Paint result. Moreover, between the black title text and the red area with white text, in Lanczos result there are some noise, which does not exist in Paint result. And at the bottom, the url on the paper is completly blur / unreadable on first result, and it's readable on Paint result.
Lanczos result:
vs Paint Result:
I'm firsly suppose that MS use 2 algorithms: 1 to downscale and a 2nd pass to sharpen the resulting picture? But as the bottom url in last example is still readable, it may be not resulting from a sharpening of downscaled result...?
Thanks
Edit
Ok, I'm a little bit stupid... the noise on pictures is due to jpeg compression quality (which I have no set in my Java code when saving picture).
Here below is the result in png, so witout noise. But result is still not readable as paint one.
Lanczos cheese png
MSPaint uses bilinear interpolation then sharpens the image with a convolution kernel:
0.0, -0.125, 0.0
-0.125, 1.5, -0.125
0.0, -0.125, 0.0
ImageMagick command:
magick image.png -scale 512 -morphology Convolve "3x3: 0.0, -0.125, 0.0 -0.125, 1.5, -0.125 0.0, -0.125, 0.0" image_resized.png
Ok I'm thinking I've got it!
In fact there are no magic in MS Paint (win7). It must used the well known Lanczos algorithm to resize image down (and up?), which seems to be the best general resampling algorithm (it seems that in XnView, in where we can choose the resampling algorithm, it's the default option).
So, I've found 2 other java implemtenations which each give differents results:
Original image : landscape-wallpaper-11a.jpg
Lanczos from Milli project here
Lanczos from "atyou" japanese blog here
Lanczos from "zattonaka" japanese blog here
Algo (Lanczos?) from MS Paint Win7
My second result set from one of my personnal picture:
From Milli project here
From "atyou" japanese blog here
From "zattonaka" japanese blog here
Algo (Lanczos?) from MS Paint Win7
The result in item list 3 seems to be the closest one to Paint result (but not same). It have sharp well readable text (second test) and sharp grass as in original image (first test).
Moreovoer, as said before (edit part of my question), the noise was due to jpeg compression when saving. Results above here, are in PNG, and so do not suffer to jpeg artefact compression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With