generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move stuff around to prep for alignment service * wip * Don't warp perspective on small segments either * initial class * Add `align` method to image alignment classes * lint * fix FourPointTransform to handle color images * Add tests against both transform backends * lints * Document new alignment function * Reorganize module structure a bit * add missing __init__
- Loading branch information
Showing
7 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .image_alignment import ImageAligner as ImageAligner |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import numpy as np | ||
|
||
from ocr.services.alignment.backends import ImageHomography | ||
|
||
|
||
class ImageAligner: | ||
def __init__(self, aligner=ImageHomography): | ||
self.aligner = aligner | ||
|
||
def align(self, source_image: np.ndarray, template_image: np.ndarray) -> np.ndarray: | ||
""" | ||
Aligns an image using the specified image alignment backend. | ||
source_image: the image to be aligned, as a numpy ndarray. | ||
template_image: the image that `source_image` will be aligned against, as a numpy ndarray. | ||
May not be used for all image alignment backends. | ||
""" | ||
aligned_image = self.aligner.align(source_image, template_image) | ||
return aligned_image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters