Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14676

Re: Bicubic interpolation suddenly is no better than bilinear.

From BGB <cr88192@hotmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Bicubic interpolation suddenly is no better than bilinear.
Date 2012-05-20 11:59 -0500
Organization albasani.net
Message-ID <jpb7u5$lia$1@news.albasani.net> (permalink)
References <d389e99e-2fc7-40dd-b07d-90140db4f380@w19g2000yqb.googlegroups.com> <nospam-B8112C.07265719052012@news.aioe.org> <fcd6a322-426d-40c7-af97-f4bd62addd5e@h10g2000pbi.googlegroups.com> <9d143d01-dcf4-4343-9477-3ffbcd3027e1@ra8g2000pbc.googlegroups.com>

Show all headers | View raw


On 5/19/2012 11:13 AM, Dangling Pointer wrote:
> Well, I can confirm that something's hinky. I've now tested
> downsampling a fairly noisy 9600x5400 image to 1280x720 in each of the
> following ways:
>
> * With Photoshop, using bicubic resampling.
> * With Java, using the process of repeatedly halving the size of the
>    input with AffineTransformOp and then making the final rescale when
>    the input is less than or equal to twice the size of the
>    destination, and using each of:
>    * TYPE_NEAREST_NEIGHBOR
>    * TYPE_BILINEAR
>    * TYPE_BICUBIC
>    * RenderingHints with interpolation set to bicubic and render set
>      to quality.
> * With Java, using Graphics.drawImage and RenderingHints set to
>    bicubic/quality
> * With Java, using getScaledInstance with SCALE_AREA_AVERAGING
>
> The results were:
>
> Best quality: Photoshop and SCALE_AREA_AVERAGING are about on a par
> and heads and shoulders above the rest.
>
> Next: iterative rescaling using either TYPE_BILINEAR, TYPE_BICUBIC, or
> RenderingHints bicubic/quality (three-way tie).
>
> Then: iterative rescaling using TYPE_NEAREST_NEIGHBOR and drawImage
> using bicubic/quality (two-way tie).
>
> I'm no longer sure that there's a change from the earlier operation of
> this particular Java install. On closer inspection of older outputs of
> similar code, I don't see a quality difference with iterative
> "bicubic" rescaling when the downsampling ratio and input noisiness
> were comparable; the better results were from less-noisy input images
> and/or larger downsampling ratios (e.g. a 64x48 thumbnail from a
> 4000x3000 TIF).
>
> Still, something is wrong. Iterative BILINEAR rescaling is *supposed*
> to achieve comparable quality to SCALE_AREA_AVERAGING, and bicubic is
> supposed to run rings around BILINEAR for quality in turn. So
> iterative BILINEAR should be as good as SCALE_AREA_AVERAGING and
> iterative BICUBIC should be better still. Instead, they're equal to
> each other and significantly worse than SCALE_AREA_AVERAGING.
>
> On the positive side, SCALE_AREA_AVERAGING doesn't seem to be as slow
> in Java 6 as it is reputed to be (possibly this reputation is based on
> the performance of older versions). So I'll be using that for now.



quick comment:
note that you are downsampling (and by a significant factor as well), 
whereas bicubic is a filter better suited for upsampling (if used 
directly for downsampling, the quality will be terrible).

the direction that the resampling is being done is fairly important for 
which filter is being used (for general purpose image resampling, it is 
typical to detect whether the image is being upsampled or downsampled, 
and select which filter is used based on this).


instead, what is needed is to use a filter which averages the samples 
for downsampling (this is the best "simple" option). hence, something 
more like SCALE_AREA_AVERAGING.

whereas, bicubic will likely give the best quality when upsampling the 
image to a higher resolution.


otherwise, if general purpose resampling is needed (where the same image 
can be used for either upsampling or downsampling at the same time, such 
as a texture in 3D rendering), one needs a filter such as trilinear or 
tricubic.

( decided to leave out a description of how to go about implementing a 
tricubic filter, as this is a little more advanced. )

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Bicubic interpolation suddenly is no better than bilinear. Dangling Pointer <dpointer2@gmail.com> - 2012-05-18 22:58 -0700
  Re: Bicubic interpolation suddenly is no better than bilinear. Roedy Green <see_website@mindprod.com.invalid> - 2012-05-18 23:12 -0700
    Re: Bicubic interpolation suddenly is no better than bilinear. Roedy Green <see_website@mindprod.com.invalid> - 2012-05-20 22:23 -0700
  Re: Bicubic interpolation suddenly is no better than bilinear. "John B. Matthews" <nospam@nospam.invalid> - 2012-05-19 07:26 -0400
    Re: Bicubic interpolation suddenly is no better than bilinear. Dangling Pointer <dpointer2@gmail.com> - 2012-05-19 08:07 -0700
      Re: Bicubic interpolation suddenly is no better than bilinear. Dangling Pointer <dpointer2@gmail.com> - 2012-05-19 09:13 -0700
        Re: Bicubic interpolation suddenly is no better than bilinear. Jan Burse <janburse@fastmail.fm> - 2012-05-19 20:48 +0200
        Re: Bicubic interpolation suddenly is no better than bilinear. "John B. Matthews" <nospam@nospam.invalid> - 2012-05-20 09:02 -0400
        Re: Bicubic interpolation suddenly is no better than bilinear. BGB <cr88192@hotmail.com> - 2012-05-20 11:59 -0500

csiph-web