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.2.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.2-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for template_align-0.0.2.tar.gz
Algorithm Hash digest
SHA256 405107dda7598d457e2a5dc58bdf90436fc369f4919d64c4ca2be4ce0e60862d
MD5 14dad6a8d38a842434000e04ac86e6d7
BLAKE2b-256 15abdf1d6620792233abdb052cb6c866b7f7e820fd837234d7af648316f15519

See more details on using hashes here.

File details

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

File metadata

  • Download URL: template_align-0.0.2-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.11.11

File hashes

Hashes for template_align-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 015aab4d9b9ccf118c75018d66d7b61034fbe7a6c9432fb4f4e88c3f3bbd3aff
MD5 d1c0ae7b5901826399a7bf8280b1d2c4
BLAKE2b-256 c068177692fb3f835a18e2b08407542718e1e4035de4093c1c788ed030475509

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