Skip to content

Commit c5a93ff

Browse files
authored
Merge pull request #3 from leftfield-geospatial/feature-clip_round_12bit_jpeg
Feature clip round 12bit jpeg
2 parents 4bbbe1d + 63d0954 commit c5a93ff

22 files changed

+422
-229
lines changed

.github/workflows/install-test-conda-forge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Install package
3333
run: |
3434
conda info
35-
conda install homonim>=0.3.2
35+
conda install homonim>=0.4.0
3636
conda list
3737
3838
- name: Run CLI fusion test

.github/workflows/run-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: |
3131
python -m pip install --upgrade pip
3232
python -m pip install pytest pytest-xdist
33-
python -m pip install rasterio opencv-python numpy click tqdm pyyaml cloup tabulate
33+
python -m pip install rasterio opencv-python-headless numpy click tqdm pyyaml cloup tabulate
3434
3535
- name: Test with pytest
3636
timeout-minutes: 5

.github/workflows/run-unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
python -m pip install --upgrade pip
3636
python -m pip install flake8 pytest pytest-xdist pytest-cov
37-
python -m pip install rasterio opencv-python numpy tabulate click tqdm pyyaml cloup
37+
python -m pip install rasterio opencv-python-headless numpy tabulate click tqdm pyyaml cloup
3838
3939
- name: Lint with flake8
4040
run: |
@@ -49,7 +49,7 @@ jobs:
4949
python -m pytest -n auto --cov=homonim --cov-report=term-missing --cov-report=xml:coverage.xml ./tests
5050
5151
- name: Upload coverage
52-
uses: codecov/codecov-action@v3
52+
uses: codecov/codecov-action@v4
5353
with:
5454
fail_ci_if_error: false
5555
files: ./coverage.xml

README.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,21 @@ See the documentation site for more detail: https://homonim.readthedocs.io/.
3030
Installation
3131
------------
3232

33-
``homonim`` is available as a python 3 package, via ``pip`` and ``conda``.
33+
``homonim`` is available as a python 3 package, via `pip <https://pip.pypa.io/>`_ or `conda <https://docs.conda.io/projects/miniconda>`_.
3434

35-
conda
36-
~~~~~
37-
38-
Under Windows, using ``conda`` is the easiest way to resolve binary dependencies. The
39-
`Miniconda <https://docs.conda.io/en/latest/miniconda.html>`__ installation provides a minimal ``conda``.
35+
pip
36+
~~~
4037

4138
.. code:: shell
4239
43-
conda install -c conda-forge homonim
40+
pip install homonim
4441
45-
pip
46-
~~~
42+
conda
43+
~~~~~
4744

4845
.. code:: shell
4946
50-
pip install homonim
47+
conda install -c conda-forge homonim
5148
5249
.. install_end
5350

docs/background.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ The minimum *kernel shape* is *model* dependent. For the two parameter :attr:`~
5353

5454
Kernel shape can be specified with the :option:`--kernel-shape <homonim-fuse --kernel-shape>` option via the command line; or with the corresponding argument in the :meth:`homonim.RasterFuse.process` API.
5555

56-
5756
.. |geedim| replace:: ``geedim``
5857
.. _geedim: https://github.com/leftfield-geospatial/geedim

docs/cli.rst

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Command line interface
2-
----------------------
2+
======================
33

44
Getting started
5-
^^^^^^^^^^^^^^^
5+
---------------
66

77
.. include:: ../README.rst
88
:start-after: cli_start
@@ -11,7 +11,7 @@ Getting started
1111
.. _cli_running_examples:
1212

1313
Running examples
14-
~~~~~~~~~~~~~~~~
14+
^^^^^^^^^^^^^^^^
1515

1616
The examples that follow use the ``homonim`` test images. You can get these by downloading the repository directly:
1717

@@ -37,7 +37,7 @@ The commands that follow use relative paths, and should be run from *<homonim ro
3737

3838

3939
Basic fusion and comparison
40-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141

4242
The *gain-blk-offset* model and kernel shape of 5 x 5 pixels are the default fusion settings and work reasonably well for a variety of problems. Here we specify these settings to correct the test aerial images with the Sentinel-2 reference.
4343

@@ -81,7 +81,7 @@ It is possible to combine the above *fuse* and *compare* commands, using the :op
8181
8282
8383
Band matching
84-
~~~~~~~~~~~~~
84+
^^^^^^^^^^^^^
8585

8686
``homonim`` automatically matches *source* to *reference* spectral bands when these images are either RGB or have ``center_wavelength`` metadata (as is the case with the ``homonim`` test data). Subsets of *source* and/or *reference* bands to use for matching can be specified with the :option:`--src-band <homonim-fuse --src-band>` and :option:`--ref-band <homonim-fuse --ref-band>` options.
8787

@@ -122,19 +122,34 @@ Let's repeat the previous example to see how this would look. Here, we also spe
122122

123123

124124
Output file format
125-
~~~~~~~~~~~~~~~~~~
125+
^^^^^^^^^^^^^^^^^^
126126

127127
By default ``homonim`` writes output files as *GeoTIFF*\s with *DEFLATE* compression, *float32* data type and *nan* nodata value. These options are all configurable.
128128

129-
Here we create a corrected image in *JPEG* format, with *uint8* data type, *0* nodata value, and a *QUALITY* setting of *85*.
129+
Here we create a *JPEG* compressed image in *GeoTIFF* format, with *uint8* data type:
130130

131131
.. code:: shell
132132
133-
homonim fuse -od ./corrected --driver JPEG --dtype uint8 --nodata 0 -co QUALITY=85 ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif
133+
homonim fuse -od ./corrected --driver GTiff --dtype uint8 --nodata null -co COMPRESS=JPEG -co INTERLEAVE=PIXEL -co PHOTOMETRIC=YCBCR ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif
134134
135+
Setting nodata to *null* forces the writing of an internal mask. This avoids lossy compression `transparency artifacts <https://gis.stackexchange.com/questions/114370/compression-artifacts-and-gdal>`__. JPEG compression is configured to sub-sample YCbCr colour space values with the ``-co INTERLEAVE=PIXEL -co PHOTOMETRIC=YCBCR`` creation options.
136+
137+
Next, the corrected image is formatted as a 12 bit JPEG compressed GeoTIFF. A *null* nodata value is used again to write an internal mask, and the *uint16* data type gets truncated to 12 bits:
138+
139+
.. code:: shell
140+
141+
homonim fuse -od ./corrected --driver GTiff --dtype uint16 --nodata null -co COMPRESS=JPEG -co NBITS=12 ./source/ngi_rgb_byte_4.tif ./reference/sentinel2_b432_byte.tif
142+
143+
The ``-co INTERLEAVE=PIXEL -co PHOTOMETRIC=YCBCR`` creation options could also be used with this example, to further compress the RGB image.
144+
145+
.. note::
146+
147+
Support for 12 bit JPEG compression is `rasterio <https://rasterio.readthedocs.io/en/stable>`__ build / package dependent.
148+
149+
See the `GDAL docs <https://gdal.org/drivers/raster/index.html>`__ for available drivers and their parameters.
135150

136151
Usage
137-
^^^^^
152+
-----
138153

139154
.. click:: homonim.cli:cli
140155
:prog: homonim

docs/contributing.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Contributing
2+
============
3+
4+
Bug reports and feature requests are welcome, and can be made with the `github issue tracker <https://github.com/leftfield-geospatial/homonim/issues>`__.
5+
6+
If ``homonim`` is useful to you, please consider `making a donation <https://github.com/sponsors/leftfield-geospatial>`__ to fund its development.
7+
8+
While a lack of funding shouldn't prevent you from making feature requests, funded requests will be prioritised.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Contents
2626
api
2727
advanced
2828
tutorials
29+
contributing
2930

3031
* :ref:`genindex`
3132

homonim/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@
1818
"""
1919
import os
2020
import pathlib
21+
import logging
22+
import warnings
2123

24+
from rasterio.errors import NotGeoreferencedWarning
2225
from homonim.compare import RasterCompare
2326
from homonim.enums import Model, ProcCrs
2427
from homonim.fuse import RasterFuse
2528
from homonim.kernel_model import KernelModel
2629
from homonim.stats import ParamStats
2730

31+
# suppress NotGeoreferencedWarning which rasterio can raise incorrectly
32+
warnings.simplefilter('ignore', category=NotGeoreferencedWarning)
33+
34+
# Add a NullHandler to the package logger to hide logs by default. Applications can then add
35+
# their own handler(s).
36+
log = logging.getLogger(__name__)
37+
log.addHandler(logging.NullHandler())
38+
2839
if '__file__' in globals():
2940
root_path = pathlib.Path(__file__).absolute().parents[1]
3041
else:

0 commit comments

Comments
 (0)