Skip to main content

[JAVA2D] Affine Operations

3 replies [Last post]
Anonymous

Dear Java2D Users:

I am trying an affine transformation operation that works
fantastically when using JAI.create methods. However I am trying to
do the same thing using the Java2D methods. Unfortunately it works
only for AffineTransformOp.TYPE_NEARESTNEIGHBOR, but does not work
well when
using AffineTransformOp.TYPE_BICUBIC. The image becomes
significantly brighter when using bicubic interpolation (as well as
for bilinear) I've attached two test images where it works and
doesn't work as well as some test code.

Does anyone out there have any ideas?

Thanks so much.
Sumit

try {
BufferedImage b = ImageIO.read(new File("works.png"));
AffineTransform at = new AffineTransform();
at.setToScale(5.3, 5.3);
AffineTransformOp aop = new AffineTransformOp(at,
AffineTransformOp.TYPE_BICUBIC);
b = aop.filter(b, null);
ImageIO.write(b, "png", new File("works1.png"));

b = ImageIO.read(new File("doesntwork.png"));
b = aop.filter(b, null);
ImageIO.write(b, "png", new File("doesntwork1.png"));

} catch (Exception e) {
e.printStackTrace();
}

===========================================================================
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".
[doesntwork.png]
[works.png]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dmitri Trembovetski

Hi Sumit,

it'd help if you point out the version of jdk you're using and the
platform you run it on..

Thanks,
Dmitri
Java2D Team

On Tue, Jun 14, 2005 at 08:03:43AM -0700, sumit shah wrote:
> Dear Java2D Users:
>
> I am trying an affine transformation operation that works
> fantastically when using JAI.create methods. However I am trying to
> do the same thing using the Java2D methods. Unfortunately it works
> only for AffineTransformOp.TYPE_NEARESTNEIGHBOR, but does not work
> well when
> using AffineTransformOp.TYPE_BICUBIC. The image becomes
> significantly brighter when using bicubic interpolation (as well as
> for bilinear) I've attached two test images where it works and
> doesn't work as well as some test code.
>
> Does anyone out there have any ideas?
>
> Thanks so much.
> Sumit
>
>
> try {
> BufferedImage b = ImageIO.read(new File("works.png"));
> AffineTransform at = new AffineTransform();
> at.setToScale(5.3, 5.3);
> AffineTransformOp aop = new AffineTransformOp(at,
> AffineTransformOp.TYPE_BICUBIC);
> b = aop.filter(b, null);
> ImageIO.write(b, "png", new File("works1.png"));
>
>
> b = ImageIO.read(new File("doesntwork.png"));
> b = aop.filter(b, null);
> ImageIO.write(b, "png", new File("doesntwork1.png"));
>
> } catch (Exception e) {
> e.printStackTrace();
> }
>
>
>
> ===========================================================================
> 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".

sumit shah

Hi Guys,

Sorry for the omission. Here is my platform:

Windows XP Service Pack 2
JDK 1.5.0_03
JAI 1.1.2_01

However I have seen this problem with JDK 1.4.2 as well.

Doing the same operation in JAI with the same images has always
worked flawlessly with Bicubic, Bicubic2, Bilinear, and Nearest
neighbor interpolation algorithms.

Thanks,
Sumit

On Jun 14, 2005, at 8:26 AM, Dmitri Trembovetski wrote:

>
> Hi Sumit,
>
> it'd help if you point out the version of jdk you're using and the
> platform you run it on..
>
> Thanks,
> Dmitri
> Java2D Team
>
> On Tue, Jun 14, 2005 at 08:03:43AM -0700, sumit shah wrote:
>
>> Dear Java2D Users:
>>
>> I am trying an affine transformation operation that works
>> fantastically when using JAI.create methods. However I am trying to
>> do the same thing using the Java2D methods. Unfortunately it works
>> only for AffineTransformOp.TYPE_NEARESTNEIGHBOR, but does not work
>> well when
>> using AffineTransformOp.TYPE_BICUBIC. The image becomes
>> significantly brighter when using bicubic interpolation (as well as
>> for bilinear) I've attached two test images where it works and
>> doesn't work as well as some test code.
>>
>> Does anyone out there have any ideas?
>>
>> Thanks so much.
>> Sumit
>>
>>
>> try {
>> BufferedImage b = ImageIO.read(new File("works.png"));
>> AffineTransform at = new AffineTransform();
>> at.setToScale(5.3, 5.3);
>> AffineTransformOp aop = new AffineTransformOp(at,
>> AffineTransformOp.TYPE_BICUBIC);
>> b = aop.filter(b, null);
>> ImageIO.write(b, "png", new File("works1.png"));
>>
>>
>> b = ImageIO.read(new File("doesntwork.png"));
>> b = aop.filter(b, null);
>> ImageIO.write(b, "png", new File("doesntwork1.png"));
>>
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>>
>>
>>
>> =====================================================================
>> ======
>> 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".

Dmitri Trembovetski

Hi Sumit,

this could be a manifestation of either
4904494: Gray BufferedImage is too bright
or
4474840: JDK 1.3fcs and 1.4 not correctly displayed gray-scale image in JAI unit test

Unfortunately neither of those is high on our priority list right
now.

Thanks,
Dmitri
Java2D Team

On Tue, Jun 14, 2005 at 08:50:15AM -0700, sumit shah wrote:
> Hi Guys,
>
> Sorry for the omission. Here is my platform:
>
> Windows XP Service Pack 2
> JDK 1.5.0_03
> JAI 1.1.2_01
>
> However I have seen this problem with JDK 1.4.2 as well.
>
> Doing the same operation in JAI with the same images has always
> worked flawlessly with Bicubic, Bicubic2, Bilinear, and Nearest
> neighbor interpolation algorithms.
>
> Thanks,
> Sumit
>
> On Jun 14, 2005, at 8:26 AM, Dmitri Trembovetski wrote:
>
> >
> > Hi Sumit,
> >
> > it'd help if you point out the version of jdk you're using and the
> > platform you run it on..
> >
> > Thanks,
> > Dmitri
> > Java2D Team
> >
> >On Tue, Jun 14, 2005 at 08:03:43AM -0700, sumit shah wrote:
> >
> >>Dear Java2D Users:
> >>
> >>I am trying an affine transformation operation that works
> >>fantastically when using JAI.create methods. However I am trying to
> >>do the same thing using the Java2D methods. Unfortunately it works
> >>only for AffineTransformOp.TYPE_NEARESTNEIGHBOR, but does not work
> >>well when
> >>using AffineTransformOp.TYPE_BICUBIC. The image becomes
> >>significantly brighter when using bicubic interpolation (as well as
> >>for bilinear) I've attached two test images where it works and
> >>doesn't work as well as some test code.
> >>
> >>Does anyone out there have any ideas?
> >>
> >>Thanks so much.
> >>Sumit
> >>
> >>
> >> try {
> >> BufferedImage b = ImageIO.read(new File("works.png"));
> >> AffineTransform at = new AffineTransform();
> >> at.setToScale(5.3, 5.3);
> >> AffineTransformOp aop = new AffineTransformOp(at,
> >>AffineTransformOp.TYPE_BICUBIC);
> >> b = aop.filter(b, null);
> >> ImageIO.write(b, "png", new File("works1.png"));
> >>
> >>
> >> b = ImageIO.read(new File("doesntwork.png"));
> >> b = aop.filter(b, null);
> >> ImageIO.write(b, "png", new File("doesntwork1.png"));
> >>
> >> } catch (Exception e) {
> >> e.printStackTrace();
> >> }
> >>
> >>
> >>
> >>=====================================================================
> >>======
> >>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".