I read this today:

http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html

This article mentions a technique (with a working code sample in Java)
that increases the image quality markedly when performing image
resizing where the target size is less than half the original size.
The article recommends that when reducing the size of an image by more
than 50% that the operation be done in stages using bilinear filtering
(repeatedly reducing the size by 50% until you reach a size where the
next 50% reduction will result in a new size _smaller_ than the target
size - then simply resize normally).

I implemented a CF function that mimics what the implementation of
getScaledInstance() does in the above linked article by using
ImageResize() in a loop. The result for most of the images I tried is
a tremendous improvement over simply calling ImageResize() once.

Comparison:

Height of 1500 to new height of 181

http://www.mediafire.com/?av4p21u308itxgb (normal resize)
http://www.mediafire.com/?e66lonlm9rds36v (multistep resize)

Height of 1500 to new height of 400

http://www.mediafire.com/?knt39f1d8c488oo (normal resize)
http://www.mediafire.com/?r75sqxlvtyvqgdq (multistep resize)

As you can see the difference in perceived quality is quite dramatic

I am posting here because my thought was that it would be much more
efficient to do this internally within the ImageResize() call rather
than externally. My thought was that inside of ImageResize() the
multistep resize could be implemented using the following as a
condition:

1. The quality argument is set to "bilinear" (this doesn't work well
otherwise) AND
         a. The width is specified AND the new width is less than half
the original width OR
         b. The height is specified AND the new height is less than
half the original height OR
         c. Both the width and height are specified and both are less
than half of the originals

If the above is true then perform the resize in multiple steps as
outlined in the article above, otherwise use the existing resize code.
This would require no changes to the calling interface - it would just
"do the right thing"...

Thoughts?

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

Reply via email to