We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Image resizing causes pixelation/blurring
Page Index Toggle Pages: 1
Image resizing causes pixelation/blurring (Read 509 times)
Image resizing causes pixelation/blurring
Apr 9th, 2008, 8:47pm
 
Hi
I'm trying to use bitmaps of fonts and randomly scaling them onto the screen, from the orginal size right down to about 5 x 5.
However the image resizing isnt the best, whether using P3D or JAVA2D the results when scaling from say a 500 x 500 bitmap of a letter down to say 20 x 20 are really poor.  I've tried all sorts of ideas, I could go the vector outline way, but I'd rather find a better way of rescaling bitmaps all together.

Does anyone know of any libraries/hacks that can do image resizing as good as photoshop?

Thanks!

Glenn.
Re: Image resizing causes pixelation/blurring
Reply #1 - Apr 9th, 2008, 10:52pm
 
The best image downscaling routines use frequency based filtering to achieve their results.  I.e. removing a lot of the high frequencies that become noisy moire-junk when shrunk down.  So, using a 2D FFT of the image is how the big boys do it, however there is an easy way.

Just blur the image before scaling it down.
Re: Image resizing causes pixelation/blurring
Reply #2 - Apr 9th, 2008, 11:09pm
 
Thank you!

Has helped a lot,
shouldn't be too much trouble to work out an algorithm to blur the source image in ratio to how small it's being scaled.
At least I know there's a solution!

The FFT thing sounds sexy, I'll look into it too,

Cheers,
Glenn.
Re: Image resizing causes pixelation/blurring
Reply #3 - Apr 11th, 2008, 7:38pm
 
with JAVA2D, smooth() improves image smoothing as well:
http://processing.org/reference/smooth_.html

with P3D, you can use hint(ENABLE_ACCURATE_TEXTURES)
http://processing.org/reference/hint_.html
Re: Image resizing causes pixelation/blurring
Reply #4 - Apr 12th, 2008, 8:29pm
 
I didn't notice any difference with the hint swicthed on, and I would always use smooth() with java2d anyway, but movaxs solution is working out though,
thanks,
G.
Page Index Toggle Pages: 1