numpyimage 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {numpyimage-2.0.0/numpyimage.egg-info → numpyimage-2.1.0}/PKG-INFO +1 -1
- numpyimage-2.1.0/npimage/align_scratch.py +50 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/graphics.py +2 -1
- {numpyimage-2.0.0 → numpyimage-2.1.0/numpyimage.egg-info}/PKG-INFO +1 -1
- {numpyimage-2.0.0 → numpyimage-2.1.0}/numpyimage.egg-info/SOURCES.txt +1 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/setup.py +1 -1
- {numpyimage-2.0.0 → numpyimage-2.1.0}/LICENSE +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/MANIFEST.in +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/README.md +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/__init__.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/align.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/core.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/filetypes/__init__.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/filetypes/pbm.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/nrrd_utils.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/operations.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/npimage/utils.py +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/numpyimage.egg-info/dependency_links.txt +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/numpyimage.egg-info/requires.txt +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/numpyimage.egg-info/top_level.txt +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/requirements.txt +0 -0
- {numpyimage-2.0.0 → numpyimage-2.1.0}/setup.cfg +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def align(im1, im2, num_divisions=4):
|
|
5
|
+
"""
|
|
6
|
+
Return a translated version of im1 that is aligned with im2.
|
|
7
|
+
|
|
8
|
+
To align the images, this function divides im1 into a grid of
|
|
9
|
+
num_divisions x num_divisions regions. For each region, we find the
|
|
10
|
+
region in im2 that is most similar to it. After removing outliers
|
|
11
|
+
for which the similarity score is too low, we calculate the average
|
|
12
|
+
translation between the two images. We then shift im1 by this
|
|
13
|
+
average translation.
|
|
14
|
+
"""
|
|
15
|
+
# The code below is entirely GitHub copilot generated and needs to
|
|
16
|
+
# be looked at, finished, tested, etc
|
|
17
|
+
|
|
18
|
+
# Divide the image into a grid of num_divisions x num_divisions regions
|
|
19
|
+
height, width = im1.shape
|
|
20
|
+
region_height = height // num_divisions
|
|
21
|
+
region_width = width // num_divisions
|
|
22
|
+
|
|
23
|
+
# Initialize lists to store the translations for each region
|
|
24
|
+
translations = []
|
|
25
|
+
|
|
26
|
+
# For each region in im1, find the most similar region in im2
|
|
27
|
+
for i in range(num_divisions):
|
|
28
|
+
for j in range(num_divisions):
|
|
29
|
+
# Define the region in im1
|
|
30
|
+
top_left = (i * region_height, j * region_width)
|
|
31
|
+
bottom_right = ((i + 1) * region_height, (j + 1) * region_width)
|
|
32
|
+
region1 = im1[top_left[0]:bottom_right[0], top_left[1]:bottom_right[1]]
|
|
33
|
+
|
|
34
|
+
# Define the search region in im2
|
|
35
|
+
search_bbox = (slice(max(0, top_left[0] - region_height),
|
|
36
|
+
min(height, bottom_right[0] + region_height)),
|
|
37
|
+
slice(max(0, top_left[1] - region_width),
|
|
38
|
+
min(width, bottom_right[1] + region_width)))
|
|
39
|
+
|
|
40
|
+
# Find the most similar region in im2
|
|
41
|
+
top_left2, score = find_landmark(im2, region1, search_bbox=search_bbox)
|
|
42
|
+
|
|
43
|
+
# Add the translation to the list of translations
|
|
44
|
+
translations.append((top_left[0] - top_left2[0], top_left[1] - top_left2[1]))
|
|
45
|
+
|
|
46
|
+
# Remove outliers from the list of translations
|
|
47
|
+
translations = np.array(translations)
|
|
48
|
+
mean_translations = np.mean(translations)
|
|
49
|
+
# Shift im1 by the average translation
|
|
50
|
+
aligned_im1 = np.roll(im1, mean_translations, axis=(0, 1))
|
|
@@ -131,6 +131,7 @@ def drawline(image, pt1, pt2, value, thickness=1,
|
|
|
131
131
|
|
|
132
132
|
# TODO switch to kwargs
|
|
133
133
|
def drawtriangle(image, pt1, pt2, pt3, value, thickness=1,
|
|
134
|
+
watertight=True,
|
|
134
135
|
fill_value=None, convention='corner', out_of_bounds='ignore'):
|
|
135
136
|
|
|
136
137
|
if fill_value is None:
|
|
@@ -181,7 +182,7 @@ def drawtriangle(image, pt1, pt2, pt3, value, thickness=1,
|
|
|
181
182
|
|
|
182
183
|
# To ensure 3D triangles end up water-tight, need the thickness of the
|
|
183
184
|
# filler lines must be >1 in at least one dimension.
|
|
184
|
-
if all(thickness == 1):
|
|
185
|
+
if watertight and all(thickness == 1):
|
|
185
186
|
slopes = abs(endpt - basept)
|
|
186
187
|
if all(eq(slopes, 0)):
|
|
187
188
|
pass
|
|
@@ -9,7 +9,7 @@ with open("requirements.txt", "r") as f:
|
|
|
9
9
|
|
|
10
10
|
setuptools.setup(
|
|
11
11
|
name="numpyimage",
|
|
12
|
-
version="2.
|
|
12
|
+
version="2.1.0",
|
|
13
13
|
author="Jasper Phelps",
|
|
14
14
|
author_email="jasper.s.phelps@gmail.com",
|
|
15
15
|
description="Load, save, and manipulate image files as numpy arrays",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|