Skip to main content

Desperate Need for Hi-res ImageCutter program

5 replies [Last post]
ngnguye
Offline
Joined: 2008-03-21
Points: 0

Hello,

I would like to cut high resolution image to the JXmapKit pyramid levels (4, 16, 64, 256, etc.). The program I wrote kept crashing on me with java heap space problem. Does anyone has a similar working program that i can use or leverage from? If so please post it.

Much Appreciated!

RC

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
wikisky
Offline
Joined: 2007-11-27
Points: 0

I'm using SubsampleAverage operator in cases when regular scale operator fails due to large input image size. Here's the simplified function I'm using:

public static RenderedOp cropScaleOpAvg(String srcImgFile, double scaleFactorX, double scaleFactorY) throws IOException {
ParameterBlock pb = new ParameterBlock();
RenderedOp fullImg = JAI.create("FileLoad",srcImgFile);
pb.addSource(fullImg);
pb.add(scaleFactorX);
pb.add(scaleFactorY);
RenderedOp tileImg = JAI.create("SubsampleAverage", pb, null);
return tileImg;
}

Another way is to use input codes that support tiling, through I didn't try it yet. If you get some experience with it let me know the results.

Also, if you're dealing with jpeg, JpegTran external command-line utility can be useful to cut jpeg images into tiles without recompression.

Sergei
wikisky.org

bpb
Offline
Joined: 2004-06-23
Points: 0

> I'm using SubsampleAverage operator in cases when
> regular scale operator fails due to large input image
> size. Here's the simplified function I'm using:
>
> public static RenderedOp cropScaleOpAvg(String
> srcImgFile, double scaleFactorX, double
> scaleFactorY) throws IOException {
> ParameterBlock pb = new ParameterBlock();
> RenderedOp fullImg =
> JAI.create("FileLoad",srcImgFile);
> pb.addSource(fullImg);
> pb.add(scaleFactorX);
> pb.add(scaleFactorY);
> RenderedOp tileImg = JAI.create("SubsampleAverage",
> pb, null);
> return tileImg;
>
> Another way is to use input codes that support
> tiling, through I didn't try it yet. If you get some
> experience with it let me know the results.

Tiling will often help with memory problems.

One thing to point out with respect to this is that the jai-imageio (https://jai-imageio.dev.java.net) ImageRead operation combined with the capabilities of the TIFF reader in the same package allow untiled, uncompressed TIFF images to be tiled on the fly while reading.

Brian

> Also, if you're dealing with jpeg, JpegTran external
> command-line utility can be useful to cut jpeg images
> into tiles without recompression.
>
>
> Sergei
> wikisky.org

kirillcool
Offline
Joined: 2004-11-17
Points: 0

Have you tried using Xmx VM flag?

ngnguye
Offline
Joined: 2008-03-21
Points: 0

Yes I have but no help there.

I believe it dies when trying to read-in large file size.

BufferedImage img = ImageIO.read(imageFile);

I'm newbies to JAI and not sure where to start yet. Perhaps you have a work around?

Thanks,

RC

bpb
Offline
Joined: 2004-06-23
Points: 0

> Yes I have but no help there.
>
> I believe it dies when trying to read-in large file
> size.
>
> BufferedImage img = ImageIO.read(imageFile);

This line is going to load the entire image into memory whether it is tiled or not.

Brian

> ewbies to JAI and not sure where to start yet.
> Perhaps you have a work around?
>
> Thanks,
>
> RC