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.
相关问题
- Views base64 encoded blob in HTML with PHP
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to get the background from multiple images by
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.
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.
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:
(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.
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