Skip to main content

Bicubic downsampling API

2 replies [Last post]
989898
Offline
Joined: 2012-01-23
Points: 0

Hi,
I have an image which is having 225 ppi. I want to apply bicubic downsampling on it to 150 ppi. Can I achieve this through Java Imaging APIs ?
I tried using: AffineTransformOp aop = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
But I did not get any option of specifying the target PPI. Will be great if someone can post a sample code for this or point me in the right direction.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rgd
Offline
Joined: 2005-08-23
Points: 0

AffineTransformOp is not a JAI operation; that's pure AWT.

For JAI you'd use the "scale" operator, providing it an appropriate
Interpolation object (there are actually two bicubic ones to choose
from). Refer to the JAI javadocs for ScaleDescriptor and Interpolation.

You won't specify the rescaling in ppi but as a ratio, e.g. 150/225.
I'm not an expert on the AWT package but if you want to use
AffineTransformOp you will almost certainly have to specify the scale
factor as a ratio in a similar manner.

HTH...

-Bob

On 1/23/12 2:35 AM, forums@java.net wrote:
> Hi, I have an image which is having 225 ppi. I want to apply bicubic
> downsampling on it to 150 ppi. Can I achieve this through Java Imaging
> APIs ?
> I tried using: AffineTransformOp aop = new AffineTransformOp(at,
> AffineTransformOp.TYPE_BICUBIC); But I did not get any option of specifying
> the target PPI. Will be great if someone can post a sample code for this or
> point me in the right direction.
>
>
>
>
>
>
>

forklabs
Offline
Joined: 2006-01-19
Points: 0

Hello,

Bob is right that the operator "scale" is mostly use to scale an image:

http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-...

My experience has shown that "scale" works great to scale up an image,
but to scale down an image, in your case from 225 to 150, operator
"subsampleaverage" usually works better:

http://download.java.net/media/jai/javadoc/1.1.3/jai-apidocs/javax/media...

It has been used successfully for the image analyser tool I made
during my master degree, check paintComponent() in:

http://www-etud.iro.umontreal.ca/~leonard/Arctic%20Ice/src/java/tools/ca...

Regards,