Skip to content

Commit

Permalink
Closes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwel committed Oct 18, 2023
1 parent e8886e9 commit d1702d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ transf, (matched_source_xy, matched_target_xy) = find_transform(source_xy, targe

```


**WARNING:** The Astroalign [`find_transform`](https://astroalign.quatrope.org/en/latest/tutorial.html#finding-the-transformation) function takes both coordinate lists and images as input, while the Aafitrans `find_transform` function only takes coordinate lists as input.

## Documentation for `find_transform` function

The `find_transform` function estimates the transform between two sets of control points, source and target. It returns a GeometricTransform object `T` ([see scikit-image documentation for details](https://scikit-image.org/docs/stable/auto_examples/transform/plot_transform_types.html#sphx-glr-auto-examples-transform-plot-transform-types-py)) that maps pixel x, y indices from the source image s = (x, y) into the target (destination) image t = (x, y).
Expand Down
18 changes: 11 additions & 7 deletions src/aafitrans/aafitrans.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from collections import Counter
from skimage import transform

__version__ = "0.2.0"
__version__ = "0.2.1"


# Arun and Horn's method.
Expand Down Expand Up @@ -304,26 +304,31 @@ def find_transform(
If no transformation is found.
"""

if np.array(source).shape[1] != 2 or np.array(target).shape[1] != 2:
raise ValueError(
"The source and target coordinate lists must have two columns."
)

try:
source = get_unique_array(source)
target = get_unique_array(target)
except Exception:
raise TypeError("Input type for source not supported.")
raise TypeError("Input type for source or target not supported.")

try:
source_controlp = np.array(source)[:max_control_points]
target_controlp = np.array(target)[:max_control_points]
except Exception:
raise TypeError("Input type for source not supported.")
raise TypeError("Input type for source or target not supported.")

# Check for low number of reference points
if len(source_controlp) < 3:
raise ValueError(
"Reference stars in source image are less than the " "minimum value (3)."
"Reference stars in source image are less than the minimum value (3)."
)
if len(target_controlp) < 3:
raise ValueError(
"Reference stars in target image are less than the " "minimum value (3)."
"Reference stars in target image are less than the minimum value (3)."
)

source_invariants, source_asterisms = _generate_invariants(
Expand Down Expand Up @@ -486,8 +491,7 @@ def _ransac(

if good_fit is None:
raise MaxIterError(
"List of matching triangles exhausted before an acceptable "
"transformation was found"
"List of matching triangles exhausted before an acceptable transformation was found"
)

better_fit = best_fit
Expand Down

0 comments on commit d1702d7

Please sign in to comment.