-->

very large image manipulation and tiling

2020-02-15 04:09发布

问题:

I need a software or program in Java or a method for tiling very large images (bigger than 140MB). I have used ImageMagick and convert tools Photoshop and Corel Draw and Matlab (in Windows), but I have a problem with memory overload. ImageMagick is very slow and result is not desirable. I don't know how can I only load a small part of image to memory without loading the whole image from harddisk.

回答1:

If you use native code, libraries such as libjeg give you scanline access to to images - you'd at most need to load 16 scanlines at a time.



回答2:

You should take a look at the Java Advanced Imaging (JAI) API, which provides out-of-the-box support for tiling large images. It's a somewhat complicated API and documentation is a tad sparse, but we've used it in a project for viewing very tall (but narrow) images that are around 60 mb a piece.

Here are a few links to get you started:

Process images in Java with JAI

JAI project homepage



回答3:

It is not Java, but Inter Performance Primitives (IPP) have set of functions for image manipulation that work on tiles. You can probably interface these functions from Java.



回答4:

JAI is platform dependent and seems like a dead project today.

I advise using the open-source program imagemagick. Although it is platform dependent, it is available for the same platforms as JAI, but with full community support.

The trick about large images about imagemagick is using its "stream"-command instead of the convert command. Stream only reads the relevant portion of the image and saves the extracted part as raw data. You then need "convert" to save the small raw data as jpeg.

Example to save a tile from large.jpeg of size 800x600 from position 0x0 to tile.jpeg:

    stream -extract 800x600+0+0 large.jpeg tile.rgb

    convert -depth 8 -size 800x600 rgb:tile.rgb tile.jpeg

(When running on windows, be sure to use ImageMagick's convert.exe, as there is a windows command named "convert".)

When working with TIFF-images only, apache Sanselan could be the right choice - it is a pure-java imaging lib. Also, JAI seems to contain a platform independent codec for TIFF.