Skip to main content

Align images based on a template

Project description

template-align

Align images based on a template

Installation

Create and select your environment using your favorite environmant management tool, e.g.

python -m venv template-environment
source template-environment/bin/activate

and install via

pip install template-align

for a editable installation, clone this project and pipinstall it in development mode

clone git@github.com:mathiaszinnen/template-align.git
cd template-align
pip install -e .

Usage

Command Line

To align a folder of images according to a template image run the alignment tool as follows:

template-align PATH/TO/TEMPLATE.jpg PATH/TO/IMAGEDIR 

Note that the path arguments have to be adapted.

By default the aligned images will be saved to ./output/aligned relative to the current working directory. The output dir can be changed using the --output-dir flag.

template-align PATH/TO/TEMPLATE.jpg PATH/TO/IMAGEDIR --output_dir PATH/TO/OUTPUTDIR

Visualizations of the mappings can be enabled via the --visualize flag. They will be saved to a matches subdirectory below the specified output directory.

template-align PATH/TO/TEMPLATE.jpg PATH/TO/IMAGEDIR --visualize 

Python

To align images within python, simply import template-align and invoke the align function:

import os
import cv2
from glob import glob
from template-align import align

image_dir_path = os.path.join('path','to','images')
template_path = os.path.join('path','to','template.jpg')
image_paths = glob.glob(os.path.join(image_dir_path,'*.jpg'))
image_names = [fn for fn in os.listdir(image_dir_path) if os.path.splitext(fn)[-1] == '.jpg']
images = [cv2.imread(p) for p in image_paths]
template = cv2.imread(template_path)

aligned_images = align(images, template, visualization_path=None, image_names=image_names)

Acknowledgements

Thank you to Jeta Sopa whose work on template alignment this project is based on.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

template_align-0.0.1.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

template_align-0.0.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file template_align-0.0.1.tar.gz.

File metadata

  • Download URL: template_align-0.0.1.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for template_align-0.0.1.tar.gz
Algorithm Hash digest
SHA256 367215915cc45cdb840f41b082bec166ed40f1bb91b55b9a3df70c0dd37c6774
MD5 70157c69c79ff9e5bd3db3a7c53adbd0
BLAKE2b-256 7e5ba164de9e7c8be8157a48f3c466b5055cb418e0e7506d2d657245c1bac17e

See more details on using hashes here.

File details

Details for the file template_align-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: template_align-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for template_align-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c169b2465968d904532ea055490015dc5e9fc81d3a8532deab010291c757a070
MD5 1cdb4efddfeb10b7cbae262eefcc53e1
BLAKE2b-256 505d0c0834601db97f58a9aacbe2419e6f862cbcb5aec670114d5a1b76173833

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page