'I have 40x tiff images and i want to use them to build 20x, 10x levels. How can I do that?
My problem is that I have TIFF images with multiple levels (40x,20x,10x,5x) but some only have 40x level and I need all of them. My question is if there is any way to get 20x or other levels from 40x level images. I read about a library called vips but I don't understand how to use it to my specific problem.
Solution 1:[1]
Yes, libvips can compute the missing levels for you. For example:
$ vips copy k2.tif x.tif[pyramid]
The [pyramid] is an option to the libvips TIFF writer to enable pyramid output. You can check the result with tiffinfo:
$ tiffinfo x.tif
TIFF Directory at offset 0x9437192 (900008)
Image Width: 1450 Image Length: 2048
Tile Width: 128 Tile Length: 128
Resolution: 72.009, 72.009 pixels/inch
Bits/Sample: 8
Sample Format: unsigned integer
Compression Scheme: None
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Planar Configuration: single image plane
TIFF Directory at offset 0x11797866 (b4056a)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 725 Image Length: 1024
Tile Width: 128 Tile Length: 128
Resolution: 72.009, 72.009 pixels/inch
Bits/Sample: 8
Compression Scheme: None
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Planar Configuration: single image plane
TIFF Directory at offset 0x12388198 (bd0766)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 362 Image Length: 512
Tile Width: 128 Tile Length: 128
Resolution: 72.009, 72.009 pixels/inch
Bits/Sample: 8
Compression Scheme: None
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Planar Configuration: single image plane
TIFF Directory at offset 0x12585098 (c0088a)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 181 Image Length: 256
Tile Width: 128 Tile Length: 128
Resolution: 72.009, 72.009 pixels/inch
Bits/Sample: 8
Compression Scheme: None
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Planar Configuration: single image plane
TIFF Directory at offset 0x12634494 (c0c97e)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 90 Image Length: 128
Tile Width: 128 Tile Length: 128
Resolution: 72.009, 72.009 pixels/inch
Bits/Sample: 8
Compression Scheme: None
Photometric Interpretation: RGB color
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 3
Planar Configuration: single image plane
You can see it's written a five level pyramid, with each level being a tiled TIFF with 128 x 128 pixel tiles. That might or might not be correct for your application, you'd need to give a lot more information. For example:
$ vips copy k2.tif x.tif[pyramid,compression=jpeg,Q=85,tile-width=256,tile-height=256]
Might be better. Check the docs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jcupitt |
