Skip to content

Instantly share code, notes, and snippets.

@martinberoiz
Created October 22, 2020 17:17
Show Gist options
  • Save martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32 to your computer and use it in GitHub Desktop.
Save martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32 to your computer and use it in GitHub Desktop.
Transforming a color image with astroalign
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