Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > problem using JAI bilinear interpolation to scale a bufferedimage

Reply
Thread Tools

problem using JAI bilinear interpolation to scale a bufferedimage

 
 
Raj
Guest
Posts: n/a
 
      11-25-2003
Hi ,
I am trying to write a function which rescales a bufferedimage using
JAI biliner interpolation

But it seems the rescaled image looses the data and now only a part of
the rescaled image is visible.I read the JAI documentation and read
somewhere that its because of not giving the proper renderinghint to
extend the border.
So i created the renderinghint and added it to the the JAI.create
method,still the result is same.

What am i doing wrong???I am new to this and am totally flabbergasted

Help me!!!

Copying the code below

Thanx a lot
Raj


public static BufferedImage _rescale(BufferedImage image, float
xScale,
float yScale)
{
if((xScale == 1.0f)&& (yScale == 1.0f)){return image;}
// Interpolation interp = Interpolation.getInstance(
// Interpolation.INTERP_BICUBIC);
Interpolation interp =
Interpolation.getInstance(Interpolation.INTERP_BIL INEAR);
ParameterBlock params = new ParameterBlock();
params.addSource(image);
params.add(xScale);
params.add(yScale);

/** Add x translate */
params.add(0.0F);

/** Add y translate */
params.add(0.0F);

/** Adds interpolation method */
params.add(interp);


RenderingHints rh = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDE R_COPY));





RenderedOp outputImage = JAI.create("scale", params,rh);
//RenderedOp outputImage = JAI.create("scale", params);
Raster raster = outputImage.getData();
//BufferedImage result=new BufferedImage();
BufferedImage result = new BufferedImage(raster.getWidth(),
raster.getHeight(),
IMAGE_TYPE);

System.out.println(raster.getWidth()+"---"+
raster.getHeight());
result.setData(raster);
return result;
}
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-25-2003
Please do not multi-post, Raj, it is worse
than cross-posting.

"Raj" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
...
> I am trying to write a function which rescales a bufferedimage using
> JAI biliner interpolation




 
Reply With Quote
 
 
 
 
ak
Guest
Posts: n/a
 
      11-25-2003
better you ask JAI-interest group -
http://swjscmail1.sun.com/archives/jai-interest.html


"Raj" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> Hi ,
> I am trying to write a function which rescales a bufferedimage using
> JAI biliner interpolation
>
> But it seems the rescaled image looses the data and now only a part of
> the rescaled image is visible.I read the JAI documentation and read
> somewhere that its because of not giving the proper renderinghint to
> extend the border.
> So i created the renderinghint and added it to the the JAI.create
> method,still the result is same.
>
> What am i doing wrong???I am new to this and am totally flabbergasted
>
> Help me!!!
>
> Copying the code below
>
> Thanx a lot
> Raj
>
>
> public static BufferedImage _rescale(BufferedImage image, float
> xScale,
> float yScale)
> {
> if((xScale == 1.0f)&& (yScale == 1.0f)){return image;}
> // Interpolation interp = Interpolation.getInstance(
> // Interpolation.INTERP_BICUBIC);
> Interpolation interp =
> Interpolation.getInstance(Interpolation.INTERP_BIL INEAR);
> ParameterBlock params = new ParameterBlock();
> params.addSource(image);
> params.add(xScale);
> params.add(yScale);
>
> /** Add x translate */
> params.add(0.0F);
>
> /** Add y translate */
> params.add(0.0F);
>
> /** Adds interpolation method */
> params.add(interp);
>
>
> RenderingHints rh = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
> BorderExtender.createInstance(BorderExtender.BORDE R_COPY));
>
>
>
>
>
> RenderedOp outputImage = JAI.create("scale", params,rh);
> //RenderedOp outputImage = JAI.create("scale", params);
> Raster raster = outputImage.getData();
> //BufferedImage result=new BufferedImage();
> BufferedImage result = new BufferedImage(raster.getWidth(),
> raster.getHeight(),
> IMAGE_TYPE);
>
> System.out.println(raster.getWidth()+"---"+
> raster.getHeight());
> result.setData(raster);
> return result;
> }



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bicubic interpolation suddenly is no better than bilinear. Dangling Pointer Java 8 05-21-2012 05:23 AM
grayscale BufferedImage from any imagetype with jai api harryos Java 0 07-19-2008 02:50 AM
JAI Problem with scale dmcquay@gmail.com Java 5 01-27-2006 04:28 PM
The Definitive Chord & Scale Bible - Literally EVERY chord and scale! Kind of Blue2 Digital Photography 1 02-08-2005 10:14 PM
Displaying Palette Tiff Image using JAI (very slow when scale operation is performed) atusc Java 1 06-04-2004 05:24 AM



Advertisments