Skip to main content

Writing out a newly created TiledImage

3 replies [Last post]
rudiga
Offline
Joined: 2009-01-22
Points: 0

Hi,

I am trying to write a class that deals with images in a way that I will find useful and I have ran into a problem.

What I am trying to do is to create an instance of an Image that can be read, edited or written as I see fit. Below is the class:

NB the forum wouldnt let me write the whole class in this box for some reason so here is a link;
http://users.aber.ac.uk/mjv08/temp/Image.java

The issue I am getting is when i create an image from scratch e.g.;

/*Creates 100x100 image with 3 bands*/
Image newImage = new Image(100, 100, 3);

Now I can get the correct details about it, I can even use the newImage.setPixel() method to edit the image and then use the newImage.getPixel() method to return it, and the changes have been made. My issue is, is that I cannot get the newly edited image to either write out or display.

Any suggestions what it is that I am doing wrong?

Martin

Reply viewing options

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

Martin,

Just out of curiosity, what's wrong with BufferedImage or PlanarImage?

Rafael
>
> I am trying to write a class that deals with images in a way that I will find useful and I have ran into a problem.
>
> What I am trying to do is to create an instance of an Image that can be read, edited or written as I see fit. Below is the class:
>
> NB the forum wouldnt let me write the whole class in this box for some reason so here is a link;
> http://users.aber.ac.uk/mjv08/temp/Image.java
>
> The issue I am getting is when i create an image from scratch e.g.;
>
> /*Creates 100x100 image with 3 bands*/
> Image newImage = new Image(100, 100, 3);
>
> Now I can get the correct details about it, I can even use the newImage.setPixel() method to edit the image and then use the newImage.getPixel() method to return it, and the changes have been made. My issue is, is that I cannot get the newly edited image to either write out or display.
>
> Any suggestions what it is that I am doing wrong?
>
> Martin
> [Message sent by forum member 'rudiga']
>
> http://forums.java.net/jive/thread.jspa?messageID=399257
>
> ---------------------------------------------------------------------
> 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

rudiga
Offline
Joined: 2009-01-22
Points: 0

I am not sure what you mean. My intention is to use a PlanarImage in the code I linked to. I have lots of code written using an Image class similar to what I have supplied, and it was using BufferedImage to store it, however it was only able to deal with RGB data. I am simply editing it to make it take advantage of the JAI and multiband datasets. Am I going about it in the wrong way? I am aware that I am using your examples from the JAI cookbook to do some of these tasks.

Rafael Santos

Rudiga,
> I am not sure what you mean. My intention is to use a PlanarImage in the code I linked to. I have lots of code written using an Image class similar to what I have supplied, and it was using BufferedImage to store it, however it was only able to deal with RGB data. I am simply editing it to make it take advantage of the JAI and multiband datasets. Am I going about it in the wrong way? I am aware that I am using your examples from the JAI cookbook to do some of these tasks.
>

Your class at http://users.aber.ac.uk/mjv08/temp/Image.java contains a
TiledImage *and* a BufferedImage. Also the constructor does not do
anything, so one could call

Image i = new Image();
i.setPixel(10,10,0,1);
i.write("out.tif");

which would cause at least some nasty exceptions.

The idea is, if you want to have an image in RGB which you could set
pixels and stuff you can use BufferedImage -- you don't even have to
extend it. ImageIO could do the input/output. If you need multiple bands
TiledImage or PlanarImage can do it. Why not use the classes that
already do what you want?

There are plenty of examples in the cookbook on how to create images
from scratch and store them, and some examples on how to read images.
What type of processing you want to do that is not present in TiledImage?

Rafael

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