Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

RDA Template Images can't decode some image tiles from RDA #727

Closed
drwelby opened this issue May 2, 2019 · 6 comments
Closed

RDA Template Images can't decode some image tiles from RDA #727

drwelby opened this issue May 2, 2019 · 6 comments

Comments

@drwelby
Copy link
Contributor

drwelby commented May 2, 2019

import os
os.environ["VIRTUAL_RDA_URL"] = "https://rda-dev.geobigdata.io/v1"
from gbdxtools import RDATemplateImage
img = RDATemplateImage('04f10eb3b38fab7c4a81923b527580e9b779815772481174465f9a8cdc05e6fa', 'Orthorectified_Pauli', calibration='sigma0')
win = img.randwindow((500,500))
win.compute()

Error is occuring here:

https://github.com/DigitalGlobe/gbdxtools/blob/master/gbdxtools/rda/fetch/threaded/libcurl/easy.py#L55

arr = imread(temp.name)

imread can't figure out the pixel mode, and is throwing the error 'unknown pixel mode'

@drwelby
Copy link
Contributor Author

drwelby commented May 2, 2019

Looks like imread can't decode RDA tiles when:

  • there is no extension
  • the file is a 32 bit tiff

CatalogImage tiles are fetched with a .tif extension, RDATemplate images have no extension.

If the tile has a .tif extension then imread will use the tifffile plugin, which can read 32-bit tiffs. If there is no extension, then it uses imageio which then fails.

Some possible solutions:

  • switch the backend to something that can decode correctly
  • add the extension, assuming we know what it is
  • sniff the extension
  • try to decode, if we hit this error try again and assume it's a tiff

The problem is hinted at here:

https://github.com/DigitalGlobe/gbdxtools/blob/master/gbdxtools/rda/fetch/threaded/libcurl/easy.py#L46

with a TODO that didn't

@drwelby
Copy link
Contributor Author

drwelby commented May 2, 2019

Modifying the tile reading to:

try:
    arr = imread(temp.name)
except SyntaxError:
    arr = imread(temp.name, plugin='tifffile')

seems to work. The question is can template nodes return tiles of other image types, and whether imageio can decode them.

@drwelby
Copy link
Contributor Author

drwelby commented May 2, 2019

Need to look at sniffing the mimetype of the image

@drwelby
Copy link
Contributor Author

drwelby commented May 2, 2019

RDA returns mimetypes for all tiles, so we'll use that to pick the appropriate image loading plugin:

https://github.com/DigitalGlobe/gbdxtools/tree/ISS-727-template-tiles

@drwelby
Copy link
Contributor Author

drwelby commented May 28, 2019

Manually merged to 0.16.7

@drwelby drwelby closed this as completed May 28, 2019
@drwelby
Copy link
Contributor Author

drwelby commented Sep 25, 2019

This error also returns the odd error about Error code: 200; in 0.16.5 the error message is misleading.

There is a workaround for 0.16.5 and earlier versions:

from skimage import io
io.use_plugin('tifffile', 'imread')

This forces the fetcher to use the tifffile plugin to decode the tiff tiles.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant