Skip to content

Commit

Permalink
deploy: ae28b01
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioContrerasH committed Aug 24, 2024
1 parent 67090df commit 04b7823
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 33 deletions.
28 changes: 21 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,16 @@ <h2 id="key-features">Key features ✨</h2>
</ul>
<h2 id="installation">Installation ⚙️</h2>
<p>Install the latest version from PyPI:</p>
<div class="highlight"><pre><span></span><code>pip<span class="w"> </span>install<span class="w"> </span>satalign
<p><div class="highlight"><pre><span></span><code>pip<span class="w"> </span>install<span class="w"> </span>satalign
</code></pre></div>
To use the <code>PCC</code> module, you need to install additional dependencies:</p>
<p><div class="highlight"><pre><span></span><code>pip<span class="w"> </span>install<span class="w"> </span>satalign<span class="o">[</span>pcc<span class="o">]</span>
</code></pre></div>
Alternatively, if you already have satalign installed:</p>
<p><div class="highlight"><pre><span></span><code>pip<span class="w"> </span>install<span class="w"> </span>scikit-image
</code></pre></div>
To use the LGM module, you need to install additional dependencies:</p>
<div class="highlight"><pre><span></span><code>pip<span class="w"> </span>install<span class="w"> </span>satalign<span class="o">[</span>deep<span class="o">]</span>
</code></pre></div>
<h2 id="how-to-use">How to use 🛠️</h2>
<h3 id="align-an-eeimagecollection-with-satalignpccpcc">Align an ee.ImageCollection with <code>satalign.pcc.PCC</code> 🌍</h3>
Expand All @@ -541,13 +550,12 @@ <h4 id="load-libraries">Load libraries</h4>
<span class="kn">import</span> <span class="nn">fastcubo</span>
<span class="kn">import</span> <span class="nn">satalign</span>
<span class="kn">import</span> <span class="nn">satalign.pcc</span>
<span class="kn">import</span> <span class="nn">satalign.ecc</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">Image</span><span class="p">,</span> <span class="n">display</span>
</code></pre></div>
<h4 id="auth-and-init-gee">Auth and Init GEE</h4>
<div class="highlight"><pre><span></span><code><span class="c1"># Initialize depending on the environment</span>
<span class="n">ee</span><span class="o">.</span><span class="n">Autenticate</span><span class="p">()</span>
<span class="n">ee</span><span class="o">.</span><span class="n">Authenticate</span><span class="p">()</span>
<span class="n">ee</span><span class="o">.</span><span class="n">Initialize</span><span class="p">(</span><span class="n">opt_url</span><span class="o">=</span><span class="s2">&quot;https://earthengine-highvolume.googleapis.com&quot;</span><span class="p">)</span> <span class="c1"># project = &quot;name&quot;</span>
</code></pre></div>
<h4 id="dataset">Dataset</h4>
Expand Down Expand Up @@ -623,8 +631,11 @@ <h4 id="graphics">Graphics</h4>
<img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/s2animation1.gif" width="100%">
</p>

<p>Here's an addition to clarify that <code>datacube</code> and <code>reference_image</code> have already been defined:</p>
<h3 id="align-an-image-collection-with-sataligneececc">Align an Image Collection with <code>satalign.eec.ECC</code> 📚</h3>
<div class="highlight"><pre><span></span><code><span class="c1"># Initialize the ECC model</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">satalign.ecc</span>

<span class="c1"># Initialize the ECC model</span>
<span class="n">ecc_model</span> <span class="o">=</span> <span class="n">satalign</span><span class="o">.</span><span class="n">ecc</span><span class="o">.</span><span class="n">ECC</span><span class="p">(</span>
<span class="n">datacube</span><span class="o">=</span><span class="n">s2_datacube</span><span class="p">,</span>
<span class="n">reference</span><span class="o">=</span><span class="n">reference_image</span><span class="p">,</span>
Expand All @@ -634,10 +645,13 @@ <h3 id="align-an-image-collection-with-sataligneececc">Align an Image Collection
<span class="n">aligned_cube</span><span class="p">,</span> <span class="n">warp_matrices</span> <span class="o">=</span> <span class="n">ecc_model</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</code></pre></div>
<h3 id="align-using-local-features-with-satalignlgmlgm">Align using Local Features with <code>satalign.lgm.LGM</code> 🧮</h3>
<div class="highlight"><pre><span></span><code><span class="c1"># Initialize the LGM model</span>
<p>Here's the updated version with a note about using floating-point values or scaling:</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">satalign.lgm</span>

<span class="c1"># Initialize the LGM model</span>
<span class="n">lgm_model</span> <span class="o">=</span> <span class="n">satalign</span><span class="o">.</span><span class="n">lgm</span><span class="o">.</span><span class="n">LGM</span><span class="p">(</span>
<span class="n">datacube</span><span class="o">=</span><span class="n">datacube</span><span class="p">,</span>
<span class="n">reference</span><span class="o">=</span><span class="n">reference_image</span><span class="p">,</span>
<span class="n">datacube</span><span class="o">=</span><span class="n">datacube</span> <span class="o">/</span> <span class="mi">10_000</span><span class="p">,</span>
<span class="n">reference</span><span class="o">=</span><span class="n">reference_image</span> <span class="o">/</span> <span class="mi">10_000</span><span class="p">,</span>
<span class="n">feature_model</span><span class="o">=</span><span class="s2">&quot;superpoint&quot;</span><span class="p">,</span>
<span class="n">matcher_model</span><span class="o">=</span><span class="s2">&quot;lightglue&quot;</span><span class="p">,</span>
<span class="p">)</span>
Expand Down
17 changes: 9 additions & 8 deletions satalign/ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@

import cv2
import numpy as np
import xarray as xr

from satalign.main import SatAlign


class ECC(SatAlign):
def __init__(
self,
datacube: np.ndarray,
reference: np.ndarray,
datacube: Union[np.ndarray, xr.DataArray],
reference: Union[np.ndarray, xr.DataArray],
criteria: Tuple[int, int, float] = (cv2.TERM_CRITERIA_COUNT, 100, 0),
gauss_kernel_size: int = 3,
**kwargs,
):
"""
Args:
datacube (xr.DataArray): The data cube to be aligned. The data cube
needs to have the following dimensions: (time, bands, height, width).
reference (Optional[xr.DataArray], optional): The reference image.
The reference image needs to have the following dimensions:
(bands, height, width).
datacube (Union[np.ndarray, xr.DataArray]): Data cube to align with
dimensions (time, bands, height, width). Ensure values are
floats; if not, divide by 10,000.
reference (Union[np.ndarray, xr.DataArray]): Reference image with
dimensions (bands, height, width). Ensure values are floats;
if not, divide by 10,000.
criteria (Tuple[int, int, float], optional): The strategy for the termination
of the iterative search algorithm. The cv2.TERM_CRITERIA_COUNT indicates
that the algorithm should terminate after a certain number of iterations.
Expand Down
23 changes: 14 additions & 9 deletions satalign/lgm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from typing import List, Optional, Tuple, Union

import xarray as xr
import numpy as np
import torch

Expand All @@ -13,22 +14,22 @@
class LGM(SatAlign):
def __init__(
self,
datacube: np.ndarray,
reference: np.ndarray,
datacube: Union[np.ndarray, xr.DataArray],
reference: Union[np.ndarray, xr.DataArray],
feature_model: str = "superpoint",
matcher_model: str = "lightglue",
max_num_keypoints: int = 2048,
device: str = "cpu",
**kwargs,
):
"""
Args:
datacube (xr.DataArray): The data cube to be aligned. The data cube
needs to have the following dimensions: (time, bands, height, width).
reference (Optional[xr.DataArray], optional): The reference image.
The reference image needs to have the following dimensions:
(bands, height, width).
datacube (Union[np.ndarray, xr.DataArray]): Data cube to align with
dimensions (time, bands, height, width). Ensure values are
floats; if not, divide by 10,000.
reference (Union[np.ndarray, xr.DataArray]): Reference image with
dimensions (bands, height, width). Ensure values are floats;
if not, divide by 10,000.
feature_model (str, optional): The feature extractor model. Defaults to
'superpoint'. Options are: 'superpoint'. Options are: 'superpoint',
'disk', 'sift', 'aliked', 'doghardnet'.
Expand Down Expand Up @@ -190,7 +191,11 @@ def get_reference_points(self) -> dict:
"""

# Create the reference layer (H x W) to torch
reference_layer = self.create_layer(img=self.reference[self.rgb_bands])
if isinstance(self.reference, xr.DataArray):
reference_layer = self.create_layer(img=self.reference.values)
else:
reference_layer = self.create_layer(img=self.reference)

reference_layer_torch = (
torch.from_numpy(reference_layer).float()[None].to(self.device)
)
Expand Down
17 changes: 9 additions & 8 deletions satalign/pcc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import warnings
from typing import List, Optional, Tuple, Union

import xarray as xr
import numpy as np
from skimage.registration import phase_cross_correlation

Expand All @@ -10,22 +11,22 @@
class PCC(SatAlign):
def __init__(
self,
datacube: np.ndarray,
reference: np.ndarray,
datacube: Union[np.ndarray, xr.DataArray],
reference: Union[np.ndarray, xr.DataArray],
upsample_factor: Optional[int] = 50,
space: Optional[str] = "real",
disambiguate: Optional[bool] = False,
overlap_ratio: Optional[float] = 0.3,
**kwargs,
):
"""
Args:
datacube (xr.DataArray): The data cube to be aligned. The data cube
needs to have the following dimensions: (time, bands, height, width).
reference (Optional[xr.DataArray], optional): The reference image.
The reference image needs to have the following dimensions:
(bands, height, width).
datacube (Union[np.ndarray, xr.DataArray]): Data cube to align with
dimensions (time, bands, height, width). Ensure values are
floats; if not, divide by 10,000.
reference (Union[np.ndarray, xr.DataArray]): Reference image with
dimensions (bands, height, width). Ensure values are floats;
if not, divide by 10,000.
upsample_factor (Optional[int], optional): Upsampling factor. Images will
be registered to within ``1 / upsample_factor`` of a pixel. For example
``upsample_factor == 20`` means the images will be registered within 1/20th
Expand Down
2 changes: 1 addition & 1 deletion search/search_index.json

Large diffs are not rendered by default.

Binary file modified sitemap.xml.gz
Binary file not shown.

0 comments on commit 04b7823

Please sign in to comment.