Skip to main content

Caching tiles at beginning of processing chain

2 replies [Last post]
rhwentworth
Offline
Joined: 2004-07-02
Points: 0

I have an application in which I am reading in a variety of images from tiled TIFF-format files, translating these files using the "Translate" operator, and then composing them together into a mosaic image using the "Mosaic" operator. For efficiency, I'd like to specify a particular tile cache to cache the tiles at the beginning of the processing chain, as they are read off disk. How can I make this happen?

I have been reading images as follows:

FileSeekableStream stream = new FileSeekableStream(fileName);
RenderedImage rawImage = JAI.create("stream", stream);

My initial guess was that I could specify a particular tile cache by adding RenderingHints to the JAI.create("stream" ...) call. I've tried doing this via:

RenderedImage rawImage = JAI.create("stream", stream, new TIFFParameterBlock(), renderingHints);

or

RenderedImage rawImage = JAI.create("stream", stream, null, renderingHints);

However, JAI tries to cast the renderingHints to Integer, and so this fails.

Question: Can one specify RenderingHints (and consequently a TileCache) for the "stream" operator, and if so how? Alternatively, do I need to add an additional stage to the processing chain to accomplish what I want to do, and if so what would that look like?

Thanks,
Robert Wentworth

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rgd
Offline
Joined: 2005-08-23
Points: 0

That's odd... looks to me like that should work. The "cast to integer"
part is especially troubling... you sure it's getting the right create
function? What does your rendering hints object look like?

If it's just a matter of the stream operator itself, you could try
attaching either a noop or format operator (configured to be a noop)
after the stream, and put the cache hint on that. But it sounds more
like the rendering hints are not being interpreted properly, than that
it's a problem with the stream operator.

-Bob

On 12/1/11 8:33 AM, forums@java.net wrote:
> I have an application in which I am reading in a variety of images from
> tiled
> TIFF-format files, translating these files using the "Translate" operator,
> and then composing them together into a mosaic image using the "Mosaic"
> operator. For efficiency, I'd like to specify a particular tile cache to
> cache the tiles at the beginning of the processing chain, as they are read
> off disk. How can I make this happen?
>
> I have been reading images as follows:
>
> FileSeekableStream stream = new FileSeekableStream(fileName); RenderedImage
> rawImage = JAI.create("stream", stream);
> My initial guess was that I could specify a particular tile cache by adding
> RenderingHints to the JAI.create("stream" ...) call. I've tried doing this
> via:
>
> RenderedImage rawImage = JAI.create("stream", stream, new
> TIFFParameterBlock(), renderingHints);
> or
>
> RenderedImage rawImage = JAI.create("stream", stream, null,
> renderingHints);
> However, JAI tries to cast the renderingHints to Integer, and so this
> fails.
>
> Question: Can one specify RenderingHints (and consequently a TileCache) for
> the "stream" operator, and if so how? Alternatively, do I need to add an
> additional stage to the processing chain to accomplish what I want to
> do, and
> if so what would that look like?
>
> Thanks,
> Robert Wentworth
>
>

rhwentworth
Offline
Joined: 2004-07-02
Points: 0

Thanks.

I think I identified the problem. If I want to supply RenderingHints, the file stream needs to be passed via the ParameterBlock rather than being passed explicitly to the JAI.create(...) method. What seems to work is:

FileSeekableStream = new FileSeekableStream(file);
ParameterBlock pblock = new ParameterBlock();
pblock.add(stream);
RenderedImage rawImage = JAI.create("stream", pblock, renderingHints);

Don't know yet if the TileCache supplied via the hints is being used, but the process is running and not producing exceptions. So, looks good for now.