Skip to main content

Tiling / Displaying Large JPEG Image

5 replies [Last post]
Anonymous

Hi,

I am working with a jpeg map image (11338px * 7558px * 24 bytes per px).
Uncompressed, the image has a disk space of 32mb; compressed 10mb.
Ultimately, I want to display a smaller portion of the map selected by the
grid reference supplied by the user. However, every time I try and load the
image using JAI my JVM freezes. I have specified java arguments of -Xmx1024m
with the same result.

I am new to the JAI api, and have tried to create a tiled image / tile cache
without success. I have also tried using the examples provided in the jai
examples / demos. I have the same map images as tiffs, but I get the same
problem. Does anyone have any suggestions / pointers as to how I can work
around this problem?

Thanks,

Christina
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Luis W. Sevilla

Christina Cunningham wrote:

> Hi Mike,
>
> Thanks for you suggestions.
>
>>I hope you don't mind that I checked your math on the image sizes,
> since I have worked with images of this size and larger and 32MB
> seemed small >based on the number of pixels.
>
> I don't mind at all - my pixel dimensions are correct so the jpeg must
> have been compressed (I haven't done much work with images to date, so
> my understanding is a little sketchy... I had converted the file from
> a .ecw file and not applied any compression at first - there must have
> been some automatically applied).

maybe you can use Ermaper ECW Java SDK
(http://www.ermapper.com/downloads/download_view.aspx?PRODUCT_VERSION_ID=114)
for opening the original .ecw image. At gvSIG we're working with this
kind of images on java without problem.

>
>>The "old" JAI archives contain several threads on the topic of large
> JPEGs -- if you haven't had a chance to search there, you can find the
> archives at the >main JAI site (on java.sun.com) as opposed to java.net.
>
> Yes - I have looked there but haven't had any success finding
> anything that helps.
>
>>Since you have set the JVM memory size to 1GB this should be plenty.
> How much physical memory does your machine have, and what platform are
> you >running on?
>
> I have a dual boot (Window's XP and Linux RedHat9) machine with 20GB
> memory - 19GB of which are still free (It's a new machine :o) - I
> don't know how the partitions were configured but I would assume that
> the memory aspect is fine. I usually run Linux to programme with.
>
>>My suggestion is that you take another look at your program and make
> sure you're not creating multiple copies of the image.
>
> I am trying to use the example code on the java.net site and modifying
> that just to get the basics of displaying the image - I haven't got as
> far as writing code for what I need to do with the image.
>
>>Are the map TIFFs that you have tiled uncompressed TIFFs? If they're
> not tiled then you're back in the same boat you were with JPEG as far
> as I can tell.
>
> As far as I know, the TIFFs aren't tiled either - so I guess I have
> the same problem there too!
>
>>Second, even though this image appears to be very big, if you do have
> 1GB of RAM then you should be able to decompress it into memory and
> store it long enough to rewrite it as a tiled TIFF or something.
>
> I think I will have to give this a try although I haven't managed to
> load the image into memory yet using java!
>
> Thanks for the pointers anyway - I will have to keep trying!
>
> Christina
> ------------------------------------------------------------------------
> *From:* Nidel, Mike [mailto:mike.nidel@lmco.com]
> *Sent:* 14 April 2005 14:38
> *To:* interest@jai.dev.java.net
> *Subject:* RE: Tiling / Displaying Large JPEG Image
>
> Hello
>
> I hope you don't mind that I checked your math on the image sizes,
> since I have worked with images of this size and larger and 32MB
> seemed small based on the number of pixels.
>
> Unless you have mistyped the pixel dimensions, then your 11338 x 7558
> image is roughly 85.6 megapixels. At 24 bits per pixel, this is over
> 250MB uncompressed.
>
> Of course this doesn't directly solve your problem, but it might shed
> some light on it. Since you have set the JVM memory size to 1GB this
> should be plenty. How much physical memory does your machine have, and
> what platform are you running on?
>
> The "old" JAI archives contain several threads on the topic of large
> JPEGs -- if you haven't had a chance to search there, you can find the
> archives at the main JAI site (on java.sun.com) as opposed to java.net.
>
> Just a couple of points: first of all, none of the JPEG readers that
> are currently provided, either with the JDK or JAI or ImageIO,
> guarantees reading only a portion of a JPEG. The way I understand it,
> the core J2SE JPEG reader has the best chance of reading only a region
> of data rather than the whole file. But if you attempt to read the
> last block/tile in the image, it will have to read all of the
> preceding blocks to get to it.
>
> Second, even though this image appears to be very big, if you do have
> 1GB of RAM then you should be able to decompress it into memory and
> store it long enough to rewrite it as a tiled TIFF or something. Even
> if you end up with two full copies of the image in memory (which you
> may or may not be able to avoid) then that should only be ~500MB.
>
> My suggestion is that you take another look at your program and make
> sure you're not creating multiple copies of the image. Keep in mind
> that BufferedImage will ALWAYS contain all of the image's data in
> memory, while a RenderedImage/PlanarImage may not necessarily do so.
> So in general, you should avoid using BufferedImage with large images.
> But in the case of JPEG, since tiling is not really supported, even
> the other Image classes will require you to get all the data in one
> huge chunk.
>
> Are the map TIFFs that you have tiled uncompressed TIFFs? If they're
> not tiled then you're back in the same boat you were with JPEG as far
> as I can tell.
>
> Mike
>
>
> -----Original Message-----
> *From:* Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
> *Sent:* Thursday, April 14, 2005 6:11 AM
> *To:* interest@jai.dev.java.net
> *Subject:* Tiling / Displaying Large JPEG Image
>
> Hi,
>
> I am working with a jpeg map image (11338px * 7558px * 24 bytes
> per px). Uncompressed, the image has a disk space of 32mb;
> compressed 10mb.
> Ultimately, I want to display a smaller portion of the map
> selected by the grid reference supplied by the user. However,
> every time I try and load the image using JAI my JVM freezes. I
> have specified java arguments of -Xmx1024m with the same result.
>
> I am new to the JAI api, and have tried to create a tiled image /
> tile cache without success. I have also tried using the examples
> provided in the jai examples / demos. I have the same map images
> as tiffs, but I get the same problem. Does anyone have any
> suggestions / pointers as to how I can work around this problem?
>
> Thanks,
>
> Christina
>

--
Luis W. Sevilla
gvSIG development Team
Conselleria de Infraestructuras y Transporte
Generalitat Valenciana
Valencia - Spain
http://www.gvsig.gva.es

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

Nidel, Mike

Your 32MB file was probably compressed at a lower compression rate than
the 10MB version.

You mentioned 20GB of memory but based on your other comments, I think
we are misunderstanding each other here -- I'm talking about RAM not
hard disk space. If you right-click on My Computer and select
Properties, it should tell you how much RAM your machine has. My guess
is that, with 20GB of hard disk, you probably have 256 or 512MB of RAM,
in which case your app won't be able to run in main memory. Even if you
set the heap size to 1GB, your performance will be awful (if it works at
all) because you'll be paging large quantities of data in and out of
virtual memory.

Unless I'm mistaken, it sounds like your machine is a bit underpowered
for the task of converting these images. If you work with the TIFFs, you
will still have to process all of the data but you may not need to have
it ALL in memory at once. How large are these TIFF files?

good luck,

Mike

-----Original Message-----
From: Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
Sent: Thursday, April 14, 2005 11:40 AM
To: interest@jai.dev.java.net
Subject: RE: Tiling / Displaying Large JPEG Image

Hi Mike,

Thanks for you suggestions.

>I hope you don't mind that I checked your math on the image sizes,
since I have worked with images of this size and larger and 32MB seemed
small >based on the number of pixels.

I don't mind at all - my pixel dimensions are correct so the jpeg must
have been compressed (I haven't done much work with images to date, so
my understanding is a little sketchy... I had converted the file from a
.ecw file and not applied any compression at first - there must have
been some automatically applied).

>The "old" JAI archives contain several threads on the topic of large
JPEGs -- if you haven't had a chance to search there, you can find the
archives at the >main JAI site (on java.sun.com) as opposed to java.net.

Yes - I have looked there but haven't had any success finding anything
that helps.

>Since you have set the JVM memory size to 1GB this should be plenty.
How much physical memory does your machine have, and what platform are
you >running on?

I have a dual boot (Window's XP and Linux RedHat9) machine with 20GB
memory - 19GB of which are still free (It's a new machine :o) - I don't
know how the partitions were configured but I would assume that the
memory aspect is fine. I usually run Linux to programme with.

>My suggestion is that you take another look at your program and make
sure you're not creating multiple copies of the image.

I am trying to use the example code on the java.net site and modifying
that just to get the basics of displaying the image - I haven't got as
far as writing code for what I need to do with the image.

>Are the map TIFFs that you have tiled uncompressed TIFFs? If they're
not tiled then you're back in the same boat you were with JPEG as far as
I can tell.

As far as I know, the TIFFs aren't tiled either - so I guess I have the
same problem there too!

>Second, even though this image appears to be very big, if you do have
1GB of RAM then you should be able to decompress it into memory and
store it long enough to rewrite it as a tiled TIFF or something.

I think I will have to give this a try although I haven't managed to
load the image into memory yet using java!

Thanks for the pointers anyway - I will have to keep trying!

Christina
_____

From: Nidel, Mike [mailto:mike.nidel@lmco.com]
Sent: 14 April 2005 14:38
To: interest@jai.dev.java.net
Subject: RE: Tiling / Displaying Large JPEG Image

Hello

I hope you don't mind that I checked your math on the image sizes, since
I have worked with images of this size and larger and 32MB seemed small
based on the number of pixels.

Unless you have mistyped the pixel dimensions, then your 11338 x 7558
image is roughly 85.6 megapixels. At 24 bits per pixel, this is over
250MB uncompressed.

Of course this doesn't directly solve your problem, but it might shed
some light on it. Since you have set the JVM memory size to 1GB this
should be plenty. How much physical memory does your machine have, and
what platform are you running on?

The "old" JAI archives contain several threads on the topic of large
JPEGs -- if you haven't had a chance to search there, you can find the
archives at the main JAI site (on java.sun.com) as opposed to java.net.

Just a couple of points: first of all, none of the JPEG readers that are
currently provided, either with the JDK or JAI or ImageIO, guarantees
reading only a portion of a JPEG. The way I understand it, the core J2SE
JPEG reader has the best chance of reading only a region of data rather
than the whole file. But if you attempt to read the last block/tile in
the image, it will have to read all of the preceding blocks to get to
it.

Second, even though this image appears to be very big, if you do have
1GB of RAM then you should be able to decompress it into memory and
store it long enough to rewrite it as a tiled TIFF or something. Even if
you end up with two full copies of the image in memory (which you may or
may not be able to avoid) then that should only be ~500MB.

My suggestion is that you take another look at your program and make
sure you're not creating multiple copies of the image. Keep in mind that
BufferedImage will ALWAYS contain all of the image's data in memory,
while a RenderedImage/PlanarImage may not necessarily do so. So in
general, you should avoid using BufferedImage with large images. But in
the case of JPEG, since tiling is not really supported, even the other
Image classes will require you to get all the data in one huge chunk.

Are the map TIFFs that you have tiled uncompressed TIFFs? If they're not
tiled then you're back in the same boat you were with JPEG as far as I
can tell.

Mike

-----Original Message-----
From: Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
Sent: Thursday, April 14, 2005 6:11 AM
To: interest@jai.dev.java.net
Subject: Tiling / Displaying Large JPEG Image

Hi,

I am working with a jpeg map image (11338px * 7558px * 24 bytes per px).
Uncompressed, the image has a disk space of 32mb; compressed 10mb.
Ultimately, I want to display a smaller portion of the map selected by
the grid reference supplied by the user. However, every time I try and
load the image using JAI my JVM freezes. I have specified java arguments
of -Xmx1024m with the same result.

I am new to the JAI api, and have tried to create a tiled image / tile
cache without success. I have also tried using the examples provided in
the jai examples / demos. I have the same map images as tiffs, but I get
the same problem. Does anyone have any suggestions / pointers as to how
I can work around this problem?

Thanks,

Christina

[att1.html]

Nidel, Mike

Hello

I hope you don't mind that I checked your math on the image sizes, since
I have worked with images of this size and larger and 32MB seemed small
based on the number of pixels.

Unless you have mistyped the pixel dimensions, then your 11338 x 7558
image is roughly 85.6 megapixels. At 24 bits per pixel, this is over
250MB uncompressed.

Of course this doesn't directly solve your problem, but it might shed
some light on it. Since you have set the JVM memory size to 1GB this
should be plenty. How much physical memory does your machine have, and
what platform are you running on?

The "old" JAI archives contain several threads on the topic of large
JPEGs -- if you haven't had a chance to search there, you can find the
archives at the main JAI site (on java.sun.com) as opposed to java.net.

Just a couple of points: first of all, none of the JPEG readers that are
currently provided, either with the JDK or JAI or ImageIO, guarantees
reading only a portion of a JPEG. The way I understand it, the core J2SE
JPEG reader has the best chance of reading only a region of data rather
than the whole file. But if you attempt to read the last block/tile in
the image, it will have to read all of the preceding blocks to get to
it.

Second, even though this image appears to be very big, if you do have
1GB of RAM then you should be able to decompress it into memory and
store it long enough to rewrite it as a tiled TIFF or something. Even if
you end up with two full copies of the image in memory (which you may or
may not be able to avoid) then that should only be ~500MB.

My suggestion is that you take another look at your program and make
sure you're not creating multiple copies of the image. Keep in mind that
BufferedImage will ALWAYS contain all of the image's data in memory,
while a RenderedImage/PlanarImage may not necessarily do so. So in
general, you should avoid using BufferedImage with large images. But in
the case of JPEG, since tiling is not really supported, even the other
Image classes will require you to get all the data in one huge chunk.

Are the map TIFFs that you have tiled uncompressed TIFFs? If they're not
tiled then you're back in the same boat you were with JPEG as far as I
can tell.

Mike

-----Original Message-----
From: Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
Sent: Thursday, April 14, 2005 6:11 AM
To: interest@jai.dev.java.net
Subject: Tiling / Displaying Large JPEG Image

Hi,

I am working with a jpeg map image (11338px * 7558px * 24 bytes per px).
Uncompressed, the image has a disk space of 32mb; compressed 10mb.
Ultimately, I want to display a smaller portion of the map selected by
the grid reference supplied by the user. However, every time I try and
load the image using JAI my JVM freezes. I have specified java arguments
of -Xmx1024m with the same result.

I am new to the JAI api, and have tried to create a tiled image / tile
cache without success. I have also tried using the examples provided in
the jai examples / demos. I have the same map images as tiffs, but I get
the same problem. Does anyone have any suggestions / pointers as to how
I can work around this problem?

Thanks,

Christina

[att1.html]

Christina Cunningham

Hi Mike,

Thanks for you suggestions.

>I hope you don't mind that I checked your math on the image sizes, since I
have worked with images of this size and larger and 32MB seemed small >based
on the number of pixels.

I don't mind at all - my pixel dimensions are correct so the jpeg must have
been compressed (I haven't done much work with images to date, so my
understanding is a little sketchy... I had converted the file from a .ecw
file and not applied any compression at first - there must have been some
automatically applied).

>The "old" JAI archives contain several threads on the topic of large JPEGs
-- if you haven't had a chance to search there, you can find the archives at
the >main JAI site (on java.sun.com) as opposed to java.net.

Yes - I have looked there but haven't had any success finding anything that
helps.

>Since you have set the JVM memory size to 1GB this should be plenty. How
much physical memory does your machine have, and what platform are you
>running on?

I have a dual boot (Window's XP and Linux RedHat9) machine with 20GB memory
- 19GB of which are still free (It's a new machine :o) - I don't know how
the partitions were configured but I would assume that the memory aspect is
fine. I usually run Linux to programme with.

>My suggestion is that you take another look at your program and make sure
you're not creating multiple copies of the image.

I am trying to use the example code on the java.net site and modifying that
just to get the basics of displaying the image - I haven't got as far as
writing code for what I need to do with the image.

>Are the map TIFFs that you have tiled uncompressed TIFFs? If they're not
tiled then you're back in the same boat you were with JPEG as far as I can
tell.

As far as I know, the TIFFs aren't tiled either - so I guess I have the same
problem there too!

>Second, even though this image appears to be very big, if you do have 1GB
of RAM then you should be able to decompress it into memory and store it
long enough to rewrite it as a tiled TIFF or something.

I think I will have to give this a try although I haven't managed to load
the image into memory yet using java!

Thanks for the pointers anyway - I will have to keep trying!

Christina
_____

From: Nidel, Mike [mailto:mike.nidel@lmco.com]
Sent: 14 April 2005 14:38
To: interest@jai.dev.java.net
Subject: RE: Tiling / Displaying Large JPEG Image

Hello

I hope you don't mind that I checked your math on the image sizes, since I
have worked with images of this size and larger and 32MB seemed small based
on the number of pixels.

Unless you have mistyped the pixel dimensions, then your 11338 x 7558 image
is roughly 85.6 megapixels. At 24 bits per pixel, this is over 250MB
uncompressed.

Of course this doesn't directly solve your problem, but it might shed some
light on it. Since you have set the JVM memory size to 1GB this should be
plenty. How much physical memory does your machine have, and what platform
are you running on?

The "old" JAI archives contain several threads on the topic of large JPEGs
-- if you haven't had a chance to search there, you can find the archives at
the main JAI site (on java.sun.com) as opposed to java.net.

Just a couple of points: first of all, none of the JPEG readers that are
currently provided, either with the JDK or JAI or ImageIO, guarantees
reading only a portion of a JPEG. The way I understand it, the core J2SE
JPEG reader has the best chance of reading only a region of data rather than
the whole file. But if you attempt to read the last block/tile in the image,
it will have to read all of the preceding blocks to get to it.

Second, even though this image appears to be very big, if you do have 1GB of
RAM then you should be able to decompress it into memory and store it long
enough to rewrite it as a tiled TIFF or something. Even if you end up with
two full copies of the image in memory (which you may or may not be able to
avoid) then that should only be ~500MB.

My suggestion is that you take another look at your program and make sure
you're not creating multiple copies of the image. Keep in mind that
BufferedImage will ALWAYS contain all of the image's data in memory, while a
RenderedImage/PlanarImage may not necessarily do so. So in general, you
should avoid using BufferedImage with large images. But in the case of JPEG,
since tiling is not really supported, even the other Image classes will
require you to get all the data in one huge chunk.

Are the map TIFFs that you have tiled uncompressed TIFFs? If they're not
tiled then you're back in the same boat you were with JPEG as far as I can
tell.

Mike

-----Original Message-----
From: Christina Cunningham [mailto:christina.cunningham@qub.ac.uk]
Sent: Thursday, April 14, 2005 6:11 AM
To: interest@jai.dev.java.net
Subject: Tiling / Displaying Large JPEG Image

Hi,

I am working with a jpeg map image (11338px * 7558px * 24 bytes per px).
Uncompressed, the image has a disk space of 32mb; compressed 10mb.
Ultimately, I want to display a smaller portion of the map selected by the
grid reference supplied by the user. However, every time I try and load the
image using JAI my JVM freezes. I have specified java arguments of -Xmx1024m
with the same result.

I am new to the JAI api, and have tried to create a tiled image / tile cache
without success. I have also tried using the examples provided in the jai
examples / demos. I have the same map images as tiffs, but I get the same
problem. Does anyone have any suggestions / pointers as to how I can work
around this problem?

Thanks,

Christina

[att1.html]

Aastha Bhardwaj

Hi Christina,

>
>>Are the map TIFFs that you have tiled uncompressed TIFFs? If they're not
> tiled then you're back in the same boat you were with JPEG as far as I
> can tell.
>
> As far as I know, the TIFFs aren't tiled either - so I guess I have the
> same problem there too!

Are you able to invoke the getTileWidth() and getTileHeight() methods on
the image being read in? These methods should confirm whether or not
your TIFF is tiled.

One way to tile your TIFF images outside of JAI is to use the "tiffcp"
utility of the libtiff library package. "tiffinfo" from the same library
utility set can also tell you whether the TIFF image is tiled or not.

Aastha

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