|
Replies:
5
-
Last Post:
Jul 26, 2007 10:09 AM
by: Ken Warner
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
Why isn't BILINEAR scaling smarter?
Posted:
Jul 19, 2007 3:58 PM
|
|
|
There is an article that mentions that one can improve the look of downscaling using BILINEAR by downscaling multiple times (each time by half): http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
The paragraph in question reads: "To combat this issue, you can use a multi-step approach when downscaling by more than two times; this helps prevent the information loss issue and produces a much higher quality result that is visually quite close to that produced by Image.SCALE_AREA_AVERAGING"
My question is, why doesn't Java do this automatically under the hood? If I request BILINEAR or BICUBIC downscaling for a factor greater than two, why doesn't Java either do multistep scaling on my behalf or why doesn't the Java2D team add a new hint (to maintain backwards compatibility) which will tell Java2D to apply these filters using the multi-step method? I would much rather have this supported by the JDK than having people reinvent the wheel over and over.
Thank you, Gili
|
|
|
|
|
|
|
Re: [JAVA2D] Why isn't BILINEAR scaling smarter?
Posted:
Jul 19, 2007 4:15 PM
in response to: cowwoc
|
|
|
Couldn't you do this in a loop yourself and control the final interpolation just the way you want it?
What if the image isn't divisible by two in one of it's dimensions? I think that it's better to leave the use of interpolation in the hands of the programer.
java2d@JAVADESKTOP.ORG wrote: > There is an article that mentions that one can improve the look of downscaling using BILINEAR by downscaling multiple times (each time by half): http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html > > The paragraph in question reads: "To combat this issue, you can use a multi-step approach when downscaling by more than two times; this helps prevent the information loss issue and produces a much higher quality result that is visually quite close to that produced by Image.SCALE_AREA_AVERAGING" > > My question is, why doesn't Java do this automatically under the hood? If I request BILINEAR or BICUBIC downscaling for a factor greater than two, why doesn't Java either do multistep scaling on my behalf or why doesn't the Java2D team add a new hint (to maintain backwards compatibility) which will tell Java2D to apply these filters using the multi-step method? I would much rather have this supported by the JDK than having people reinvent the wheel over and over. > > Thank you, > Gili > [Message sent by forum member 'cowwoc' (cowwoc)] > > http://forums.java.net/jive/thread.jspa?messageID=227363 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help". > >
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Why isn't BILINEAR scaling smarter?
Posted:
Jul 24, 2007 5:31 AM
in response to: cowwoc
|
|
|
[I sent this out a few days ago, but replied to the wrong address so I don't believe it went through - sending again...jim]
The Bilinear filtering algorithm is a well known algorithm that has a very specific definition which we follow. If we automatically applied multiple steps based on the scaling factor then we would violate that definition and have to call it something else.
On a more practical note, if someone has determined that the caveats of the bilinear algorithm are sufficient for their needs and we did perform multiple steps instead of one step then we would reduce performance which that particular developer might not appreciate.
On another practical note, hardware accelerators do not perform multi-step scaling so we wouldn't be able to fire the request off to the video card and get hardware accelerated scaling (nearly free) if we instituted such a policy behind the scenes.
If we did provide that mechanism automatically then it would have to be under a different name so that the developer could buy into the specific tradeoffs that it provides (better quality for >2x downscaling at the expense of about 7x performance).
In the meantime, we publish blogs like the one you point to in order to educate our programmers about the definitions of the graphical terms and processes that our APIs allow them to access and how to use those well defined industry standard mechanisms to achieve their needs...
...jim
java2d@javadesktop.org wrote: > There is an article that mentions that one can improve the look of downscaling using BILINEAR by downscaling multiple times (each time by half): http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html > > The paragraph in question reads: "To combat this issue, you can use a multi-step approach when downscaling by more than two times; this helps prevent the information loss issue and produces a much higher quality result that is visually quite close to that produced by Image.SCALE_AREA_AVERAGING" > > My question is, why doesn't Java do this automatically under the hood? If I request BILINEAR or BICUBIC downscaling for a factor greater than two, why doesn't Java either do multistep scaling on my behalf or why doesn't the Java2D team add a new hint (to maintain backwards compatibility) which will tell Java2D to apply these filters using the multi-step method? I would much rather have this supported by the JDK than having people reinvent the wheel over and over. > > Thank you, > Gili > [Message sent by forum member 'cowwoc' (cowwoc)] > > http://forums.java.net/jive/thread.jspa?messageID=227363 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Why isn't BILINEAR scaling smarter?
Posted:
Jul 24, 2007 10:08 AM
in response to: Jim Graham
|
|
|
Bilinear interpolation uses a very small 4 pixel neighborhood to interpolate.
My experience is that it works pretty good at upscaling -- maybe not so good at downscaling. Other interpolation methods work better at down scaling because they use a larger neighborhood. Bicubic; Lanczos etc. use a 16 pixel neighborhood and they do better at downscaling because they take a weighted average over a larger neighborhood.
Automatically forcing multiple interpolations might not be the best thing to do on all images. Like for example, what if the dimensions of the image are both prime numbers. Or what if the image is really wide and not very high -- like a 360 degree panorama? How do you automatically apply a multi-step downscaling interpolation?
No API can be made flexible and smart enough to handle all possible situations. That's why programmers still have jobs.
Jim Graham wrote: > [I sent this out a few days ago, but replied to the wrong address so I > don't believe it went through - sending again...jim] > > The Bilinear filtering algorithm is a well known algorithm that has a > very specific definition which we follow. If we automatically applied > multiple steps based on the scaling factor then we would violate that > definition and have to call it something else. > > On a more practical note, if someone has determined that the caveats of > the bilinear algorithm are sufficient for their needs and we did perform > multiple steps instead of one step then we would reduce performance > which that particular developer might not appreciate. > > On another practical note, hardware accelerators do not perform > multi-step scaling so we wouldn't be able to fire the request off to the > video card and get hardware accelerated scaling (nearly free) if we > instituted such a policy behind the scenes. > > If we did provide that mechanism automatically then it would have to be > under a different name so that the developer could buy into the specific > tradeoffs that it provides (better quality for >2x downscaling at the > expense of about 7x performance). > > In the meantime, we publish blogs like the one you point to in order to > educate our programmers about the definitions of the graphical terms and > processes that our APIs allow them to access and how to use those well > defined industry standard mechanisms to achieve their needs... > > ...jim > > java2d@javadesktop.org wrote: > >> There is an article that mentions that one can improve the look of >> downscaling using BILINEAR by downscaling multiple times (each time by >> half): >> http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html >> >> >> The paragraph in question reads: "To combat this issue, you can use a >> multi-step approach when downscaling by more than two times; this >> helps prevent the information loss issue and produces a much higher >> quality result that is visually quite close to that produced by >> Image.SCALE_AREA_AVERAGING" >> >> My question is, why doesn't Java do this automatically under the hood? >> If I request BILINEAR or BICUBIC downscaling for a factor greater than >> two, why doesn't Java either do multistep scaling on my behalf or why >> doesn't the Java2D team add a new hint (to maintain backwards >> compatibility) which will tell Java2D to apply these filters using the >> multi-step method? I would much rather have this supported by the JDK >> than having people reinvent the wheel over and over. >> >> Thank you, >> Gili >> [Message sent by forum member 'cowwoc' (cowwoc)] >> >> http://forums.java.net/jive/thread.jspa?messageID=227363 >> >> =========================================================================== >> >> To unsubscribe, send email to listserv@java.sun.com and include in the >> body >> of the message "signoff JAVA2D-INTEREST". For general help, send >> email to >> listserv@java.sun.com and include in the body of the message "help". > > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help". > >
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Why isn't BILINEAR scaling smarter?
Posted:
Jul 26, 2007 3:23 AM
in response to: Ken Warner
|
|
|
> No API can be made flexible and smart enough to > handle all possible situations. That's why > programmers still have jobs.
I agree and this is especially true for image manipulation. There's no thing such a single way to do e.g. image resizing. For instance, the approach with multiple passes is good for dealing with images functional for the l&f of a desktop application, while if we'd like to do something more quality-oriented something more complex is needed (refer to this post for an example http://archives.java.sun.com/cgi-bin/wa?A2=ind0311&L=jai-interest&P=R9579&I=-3).
IMHO it's correct that Java only provides low-level APIs, that is building blocks that should be put together in different ways for different needs.
PS Sorry, this is some kind of self-promotion but this is related to the topic: http://mistral.tidalwave.it/infoglueDeliverLive/ViewPage.action?siteNodeId=368
|
|
|
|
|
|
|
|
Re: [JAVA2D] Why isn't BILINEAR scaling smarter?
Posted:
Jul 26, 2007 10:09 AM
in response to: fabriziogiudici
|
|
|
Exactly! Just look at some of the various Graphics API's that have succeeded and failed. OpenGL -- succeed -- simple, low level graphics that the programmer put together. I think, anyway I like it.
GKS -- remember GKS? -- failed. High level display lists. Multi level and really complicated.
How about Java3D? Anybody using that? VRML -- anybody using that?
What succeeds? Java2D. ImageIO and JAI. Simple low level stuff that the programmer puts together.
Anyway that's the way I see things. I have a feeling that everbody will have a different opinion....
> IMHO it's correct that Java only provides low-level APIs, that is building > blocks that should be put together in different ways for different needs.
java2d@JAVADESKTOP.ORG wrote: >>No API can be made flexible and smart enough to >>handle all possible situations. That's why >>programmers still have jobs. > > > I agree and this is especially true for image manipulation. There's no thing such a single way to do e.g. image resizing. For instance, the approach with multiple passes is good for dealing with images functional for the l&f of a desktop application, while if we'd like to do something more quality-oriented something more complex is needed (refer to this post for an example http://archives.java.sun.com/cgi-bin/wa?A2=ind0311&L=jai-interest&P=R9579&I=-3). > > IMHO it's correct that Java only provides low-level APIs, that is building blocks that should be put together in different ways for different needs. > > PS Sorry, this is some kind of self-promotion but this is related to the topic: http://mistral.tidalwave.it/infoglueDeliverLive/ViewPage.action?siteNodeId=368 > [Message sent by forum member 'fabriziogiudici' (fabriziogiudici)] > > http://forums.java.net/jive/thread.jspa?messageID=228317 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help". > >
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|