diff --git a/doc/features.md b/doc/features.md index 2058af5227b87add778b5912844b3a74f971c639..6af13551d2192376e0ddf2fee9703c4495888006 100644 --- a/doc/features.md +++ b/doc/features.md @@ -32,18 +32,64 @@ inp = pyotb.Input('my_image.tif') inp[:, :, :3] # selecting first 3 bands inp[:, :, [0, 1, 4]] # selecting bands 1, 2 & 5 -inp[:1000, :1000] # selecting 1000x1000 subset, same as inp[:1000, :1000, :] +inp[:, :, 1:-1] # removing first and last band +inp[:, :, ::2] # selecting one band every 2 bands +inp[:100, :100] # selecting 100x100 subset, same as inp[:100, :100, :] inp[:100, :100].write('my_image_roi.tif') # write cropped image to disk ``` -## Shape attributes +## Retrieving a pixel location in image coordinates -You can access the shape of any in-memory pyotb object. +One can retrieve a pixel location in image coordinates (i.e. row and column +indices) using `get_rowcol_from_xy()`: ```python -import pyotb +inp.get_rowcol_from_xy(760086.0, 6948092.0) # (333, 5) +``` -# transforming filepath to pyotb object -inp = pyotb.Input('my_image.tif') +## Reading a pixel value + +One can read a pixel value of a pyotb object using brackets, as if it was a +common array. Returned is a list of pixel values for each band: + +```python +inp[10, 10] # [217, 202, 182, 255] +``` + +!!! warning + + Accessing multiple pixels values if not computationally efficient. Please + use this with moderation, or consider numpy or pyotb applications to + process efficiently blocks of pixels. + +## Attributes + +### Shape + +The shape of pyotb objects can be retrieved using `shape`. + +```python print(inp[:1000, :500].shape) # (1000, 500, 4) ``` + +### Pixel type + +The pixel type of pyotb objects can be retrieved using `dtype`. + +```python +inp.dtype # e.g. 'uint8' +``` + +!!! note + + The `dtype` returns a `str` corresponding to values accepted by the + `pixel_type` of `write()` + +### Transform + +The transform, as defined in GDAL, can be retrieved with the `transform` +attribute: + +```python +inp.transform # (6.0, 0.0, 760056.0, 0.0, -6.0, 6946092.0) +``` \ No newline at end of file diff --git a/doc/interaction.md b/doc/interaction.md index 0195b706e2fde6089f1102f839049895f589f140..dcb87290936f6f60b65e7b66e4def90081e8c02d 100644 --- a/doc/interaction.md +++ b/doc/interaction.md @@ -1,4 +1,6 @@ -## Export to Numpy +## Numpy + +### Export to numpy arrays pyotb objects can be exported to numpy array. @@ -16,7 +18,7 @@ arr = np.asarray(calibrated) arr = calibrated.to_numpy() ``` -## Interaction with Numpy +### Interact with numpy functions pyotb objects can be transparently used in numpy functions. @@ -47,9 +49,9 @@ noisy_image.write('image_plus_noise.tif') - The georeference can not be modified. Thus, numpy operations can not change the image or pixel size -## Export to rasterio +## Rasterio -pyotb objects can also be exported in a format that is usable by rasterio. +pyotb objects can also be exported in a format usable by rasterio. For example: @@ -88,7 +90,7 @@ as the user gets the `profile` dictionary. If the georeference or pixel size is modified, the user can update the `profile` accordingly. -## Interaction with Tensorflow +## Tensorflow We saw that numpy operations had some limitations. To bypass those limitations, it is possible to use some Tensorflow operations on pyotb objects. diff --git a/doc/otb_versions.md b/doc/otb_versions.md index 50f30ee1a022aec93154c2c838723b6f83133494..aa8889d7a3b21edfe30f142e88d32412678b69fa 100644 --- a/doc/otb_versions.md +++ b/doc/otb_versions.md @@ -40,8 +40,10 @@ Here is the path precedence for this automatic env configuration : OR (for windows) : C:/Program Files ``` -N.B. : in case `otbApplication` is found in `PYTHONPATH` (and if `OTB_ROOT` -was not set), the OTB which the python API is linked to will be used. +!!! Note + + When `otbApplication` is found in `PYTHONPATH` (and `OTB_ROOT` not set), + the OTB installation where the python API is linked, will be used. ## Fresh OTB installation