nshaud / DeepNetsForEO

Deep networks for Earth Observation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is the "extract_images.py" script valid to extract DSM patches ?

PraveerSINGH opened this issue · comments

Hey,

I want to build composite patches using the DSM, NDSM and NDVI. However when I try to extract patches over normal DSM tiff images using "extract_images.py" script, I face an error saying:

=== PROCESSING DSM === 0%| | 0/3 [00:00<?, ?it/s] Traceback (most recent call last): | 0/57549 [00:00<?, ?it/s] File "extract_images.py", line 126, in <module> io.imsave('{}/{}.png'.format(DATASET_DIR + suffix + '_train', i), sample) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/io/_io.py", line 133, in imsave return call_plugin('imsave', fname, arr, plugin=plugin, **plugin_args) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/io/manage_plugins.py", line 211, in call_plugin return func(*args, **kwargs) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/io/_plugins/pil_plugin.py", line 259, in imsave img = ndarray_to_pil(arr, format_str=format_str) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/io/_plugins/pil_plugin.py", line 171, in ndarray_to_pil arr = img_as_uint(arr) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/util/dtype.py", line 325, in img_as_uint return convert(image, np.uint16, force_copy) File "/home/praveer/anaconda2/lib/python2.7/site-packages/skimage/util/dtype.py", line 205, in convert raise ValueError("Images of type float must be between -1 and 1.") ValueError: Images of type float must be between -1 and 1.
Thanks in advance.

Praveer

Yeah, because DSM images are float images and the script expects bytes. The way we actually did this was by computing the composing image for each tile by stacking DSM, NDSM and NDVI and then saving the result in a TIFF file in the [0, 255] integer format, e.g. "CompositeTileXX.tif".

Then you can apply the extract_images.py script on your "CompositeTileXX.tif" files. Sorry, it's a bit of a burden right now but it should better in a few weeks.