Is there a file format (image file) that allows random access to its sections.
For example, I have huge image file with resolution of 100000x100000 pixels and I want to read just one small section. Like a geomap with zoom levels.
I want to write some app in Java. I could use hundreds of small files and combine them somehow, but it would be much better if there is a way to do it with one huge file (or few of them).
Your ability to do that will depend on the file format you are using for the pictures. In principle, non-compressed file formats as BMP or TIFF will give you more freedom at reading specific regions.
The good news is that you have a standard Java class (see ImageReader) that allows you to do exactly what you are looking for by specifying a region of interest (read section 3.3.1 ImageReadParam).
However as I stated before, it will depend on your image format. At the ImageReader class itself you have a handy method named 'isRandomAccessEasy' that will return true if the storage format of the given image places no inherent impediment on random access to pixels (verbatim from official docs).
"but it would be much better if there is a way to do it with one huge file"
I do not think so. As Manuel said, it is complicated to access random positions of compressed image since most compression algorithms consider the entire image to maximize the compression capability. Therefore, the decompression process will use a lot memory to decompress an image of this size.
In the other hand, the file will be bigger by orders of magnitude without compression.
I think you should use the same approach used by tools like Google Maps or Zoompy. Take the original huge image and break it down in tiles. In this way, the tiles can be compressed and the visualization can be performed using much less memory.
Texture compression
Have a look at texture compression formats, which are designed to be both compressed and allow random access, to reduce bandwidth of image usage on GPU textures for 3D rendering https://en.wikipedia.org/wiki/Texture_compression :
Unlike conventional image compression algorithms, texture compression algorithms are optimized for random access.
The following formats seem to be open:
- https://www.khronos.org/opengles/sdk/tools/KTX/ https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
- https://en.wikipedia.org/wiki/Ericsson_Texture_Compression
ARM Mali AFBC is one (proprietary?) example https://www.arm.com/products/graphics-and-multimedia/mali-technologies
Random access down to 4x4 block level