Created
October 22, 2020 17:17
-
-
Save martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32 to your computer and use it in GitHub Desktop.
Transforming a color image with astroalign
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
from PIL import Image | |
import numpy as np | |
import astroalign as aa | |
source = np.array(Image.open("source.jpg")) | |
target = np.array(Image.open("target.jpg")) | |
def register_color(source, target): | |
transf = aa.find_transform(source[:,:,1], target[:,:,1])[0] | |
rgb = [] | |
for achannel in np.rollaxis(source, 2): | |
rgb.append(aa.apply_transform(transf, achannel, target[:,:,1])) | |
return np.array(rgb) | |
transformed = register_color(source, target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment