Skip to main content

Creating planarImage from bufferedimage

3 replies [Last post]
indara
Offline
Joined: 2007-11-11
Points: 0

I am having trouble with creating planarimage from a bufferedimage.
This is the code I did:

BufferedImage bi;

PlanarImage planarimage = PlanarImage.wrapRenderedImage(bi);

I tried some filters like bandmerge to create grayscale image but nothings is changed on the planarimage. What I need to do get it working is saving the planar image into file then recreate the planar image from that file with JAI.create method.

Can anyone please help on creating planarimage from bufferedimage

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bpb
Offline
Joined: 2004-06-23
Points: 0

> I am having trouble with creating planarimage from a
> bufferedimage.
> This is the code I did:
>
> BufferedImage bi;
>
> PlanarImage planarimage =
> PlanarImage.wrapRenderedImage(bi);

That's one way to do it.

> I tried some filters like bandmerge to create
> grayscale image but nothings is changed on the
> planarimage. What I need to do get it working is
> saving the planar image into file then recreate the
> planar image from that file with JAI.create method.

I don't know what you are asking here.

> Can anyone please help on creating planarimage from
> bufferedimage

You answered your own question already. If there is more, please clarify.

Brian

indara
Offline
Joined: 2007-11-11
Points: 0

I cant tried to apply some filter like bandmerge, edge detection on the planarimage that was made using bufferedimage and the result is nothing happens to the planar image.

What I did to make it work is saving the planar image and recreate the planarimage from the image that was saved.

is there a way to apply filter on planarimage that was made from bufferedimage without saving it first and reload it.

Thanks.

Nidel, Mike

It seems like you are confused because you are expecting the
PlanarImage to be modified in place by the operator. This isn't
the way JAI works.

When you do

PlanarImage planarimage = PlanarImage.wrapRenderedImage(bi);

now you have a PlanarImage representing your source. What does
your code after this look like?

If you do the following:

ParameterBlock pb = new ParameterBlock();
pb.addSource(planarimage);
JAI.create("bandmerge", pb);

This does not MODIFY the planarimage. Instead it creates a new
PlanarImage, you have to assign it to a new variable. Nothing
will change your planarimage unless you do

planarimage = JAI.create("bandmerge"...);

What you probably should do is

PlanarImage mergedImage = JAI.create("bandmerge"...);

One more thing: is there a reason why you're doing
PlanarImage.wrapRenderedImage()?
All of the JAI operators accept RenderedImage and BufferedImage is a
RenderedImage,
so you may not need to wrap the BufferedImage.

Hope this helps,

> -----Original Message-----
> From: jai-interest@javadesktop.org
> [mailto:jai-interest@javadesktop.org]
> Sent: Friday, December 07, 2007 7:50 AM
> To: interest@jai.dev.java.net
> Subject: [JAI] Re: Creating planarImage from bufferedimage
>
> I cant tried to apply some filter like bandmerge, edge
> detection on the planarimage that was made using
> bufferedimage and the result is nothing happens to the planar image.
>
> What I did to make it work is saving the planar image and
> recreate the planarimage from the image that was saved.
>
> is there a way to apply filter on planarimage that was made
> from bufferedimage without saving it first and reload it.
>
> Thanks.
> [Message sent by forum member 'indara' (indara)]
>
> http://forums.java.net/jive/thread.jspa?messageID=249025
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net