Retrieving a region of interest from an image file without reading the entire image

I am looking for a library (in any language) that is able to read an area of ​​an image file (any format) without first extracting the entire image file.

I came across several options, such as vips, which do not really store the entire image in memory, but still it seems that you need to read it completely to get started.

I understand that this may not be available for compressed formats such as jpegs, but theoretically it sounds like bmps or tiffs should consider this type of reading.

+1
source share
6 answers

libvips , , . , 100x100 PNG, :

$ time vips crop wtc.png x.jpg 0 0 100 100
real    0m0.063s
user    0m0.041s
sys 0m0.023s

( , , , , wtc.png x.jpg)

100x100 , , :

$ time vips crop wtc.png x.jpg 0 9000 100 100
real    0m3.063s
user    0m2.884s
sys 0m0.181s

JPG strip TIFF , , .

. , tiled TIFF , libvips libtiff :

$ vips copy wtc.png wtc.tif[tile]
$ time vips crop wtc.tif x.jpg 0 0 100 100
real    0m0.033s
user    0m0.013s
sys 0m0.021s
$ time vips crop wtc.tif x.jpg 0 9000 100 100
real    0m0.037s
user    0m0.021s
sys 0m0.017s

OpenSlide, vips, OpenEXR, FITS, PPM/PGM/PBM, HDR, RAW, Analyze, Matlab , , , .

, API , libvips :

http://jcupitt.imtqy.com/libvips/API/current/How-it-opens-files.md.html

crop Python pyvips:

import pyvips

image = pyvips.Image.new_from_file(input_filename, access='sequential')
tile = image.crop(left, top, width, height)
tile.write_to_file(output_filename)

access= - , libvips, , , . , , , TIFF.

. , MIME- stdout:

tile.jpegsave_mime(Q=85)

-, , JPG:

buffer = tile.write_to_buffer('.jpg', Q=85)

Q=85 JPG Q. .

+1

ITK . CanStreamRead, true , , MetaImageIO. . ITK .

+1

, TIFF. 100 × 30 .

LibTiff , ROI. , ( ).

+1

BMP () , .

TIFF , . TIFF (TIFFlib) -, . http://www.libtiff.org/libtiff.html#Tiles

0

.
, , , .

, , , , .., , .

, ROI , , .

0

Source: https://habr.com/ru/post/1693956/


All Articles