Skip to content

Commit

Permalink
Initial backend rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-loi committed Dec 27, 2022
1 parent 3f629ef commit d2582cc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
51 changes: 50 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,55 @@
from __builtin__ import isinstance


def hdr(images: "list[np.ndarray]", perform_alignment: bool = True, use_softmax: bool = True) -> np.ndarray:
"""hdr Performs exposure fusion on a list of images.
Parameters
----------
images : list[np.ndarray]
A list of RGB images to be fused, obtained through cv2.imread.
perform_alignment : bool, optional
Whether to perform preliminary alignment on the images, by default True
use_softmax : bool, optional
Whether to use softmax instead of the traditional weight normalization
algorithm, by default True
Returns
-------
np.ndarray
A single RGB HDR image, resulting from the fusion of the input images.
"""

# Check if there are at least two images
assert len(images) > 1

# Check if all images have the same dimensions
assert all([images[0].shape == elem for elem in [
img.shape for img in images]])

# Check if all images are RGB
assert all([len(img.shape) == 3 for img in images]) and all(
[img.shape[2] == 3 for img in images])

# Check if all images are uint8
assert all([isinstance(img, np.uint8) for img in images])

# Align images
images = align(images)

# Compute weights

weights = compute_weights(images, time_decay=None)

# Compute the Pyramids

# Combine the pyramids

# Collapse the pyramids

# Return the result


def compute_weights(images, time_decay):
(w_c, w_s, w_e) = (1, 1, 1)

Expand Down Expand Up @@ -218,4 +267,4 @@ def align_images(images):

hdr = exposure_fusion(align_images(images))
cv2.imwrite(f"A_{i}.png", hdr)
##fix path for mac
# fix path for mac
1 change: 1 addition & 0 deletions orb-homography.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def run_histogram_equalization(rgb_img):
cv2.resizeWindow("Warped", dst.shape[1]//8, dst.shape[0]//8)

cv2.imshow("Warped", dst)
cv2.imwrite("warped.png", dst)

cv2.waitKey(0)
except:
Expand Down
Binary file added warped.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d2582cc

Please sign in to comment.