Skip to main content

A package for template matching using Torch

Project description

hd-tmf

A high-dimensional template matching framework based on PyTorch.

Installation

pip install Hough-TMF

Usage

from hd_tmf import tmf

TMF Example

# generate a random template
tmp = np.random.rand(10, 100, 20)
# generate a random image
data = np.random.rand(100, 1000)
# calculate the cross-correlation between the template and the image
corr = tmf(tmp, data, step=1, device='cpu', moves=[], batch_size=-1, save_memory=False, max_workers=4)

Parameters

  • tmp (numpy.ndarray or torch.Tensor): The template to be matched.
  • data (numpy.ndarray or torch.Tensor): The image to search for the template.
  • step (int, optional): The step size of the convolution. Defaults to 1.
  • device (str, optional): The device to perform the computation on. Defaults to 'cpu'.
  • moves (list, optional): A list of moves to apply to the template before matching. Defaults to [].
  • batch_size (int, optional): The batch size to use for the computation. Defaults to -1.
  • save_memory (bool, optional): Whether to use half-precision floating point numbers to save memory. Defaults to False.
  • max_workers (int, optional): The maximum number of worker threads to use for the computation. Defaults to 4.

Returns

  • numpy.ndarray: The cross-correlation between the template and the image.

Hough Example

from hd_tmf import hough
data = np.random.randn(256, 256)
hough(data,freq=100,bandpass=[2,8],sl=[10,20],resample=1, sigma=1.3, low_threshold=3, high_threshold=6,theta=np.linspace(np.pi/2/90*10/100,np.pi/2/90*10,99), fil='bandpass', S_L=True,beta=0,kernel=(3,3))

Parameters

  • data (numpy.ndarray or torch.Tensor): The image to search for the template.
  • freq (int, optional): The frequency of the template. Defaults to 100.
  • bandpass (list, optional): The bandpass filter to apply to the image. Defaults to [2,8].
  • sl (list, optional): The size of the template. Defaults to [10,20].
  • resample (int, optional): The resample rate of the image. Defaults to 1.
  • sigma (float, optional): The sigma of the Gaussian filter. Defaults to 1.3.
  • low_threshold (float, optional): The low threshold of the Canny edge detector. Defaults to 3.
  • high_threshold (float, optional): The high threshold of the Canny edge detector. Defaults to 6.
  • theta (numpy.ndarray, optional): The theta of the Hough transform. Defaults to np.linspace(np.pi/2/9010/100,np.pi/2/9010,99).
  • fil (str, optional): The filter to apply to the image. Defaults to 'bandpass'.
  • S_L (bool, optional): Whether to apply the Laplacian filter to the image. Defaults to True.
  • beta (float, optional): The beta of the Laplacian filter. Defaults to 0.
  • kernel (tuple, optional): The kernel size of the Laplacian filter. Defaults to (3,3).

License

MIT License

Copyright (c) [2023] []

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

References

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

Hough-TMF-0.2.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

Hough_TMF-0.2.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file Hough-TMF-0.2.1.tar.gz.

File metadata

  • Download URL: Hough-TMF-0.2.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for Hough-TMF-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b16896d4c1280deb40bdf7ada1a43f2377be079c364dd4e441ac40a154dd9226
MD5 be50f4a0a83fc8c86b6fd65949aa29ba
BLAKE2b-256 aa68d45960da5753011ee2c2d4db32c3909b28987a88fd89aa68993dc505b1a3

See more details on using hashes here.

File details

Details for the file Hough_TMF-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: Hough_TMF-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for Hough_TMF-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b50bc3315c2adf9aa44d012369098d277234957c94fe651a8ad6b18a58921f03
MD5 f731376f9d448e54401019eafa73758e
BLAKE2b-256 dc0599e2249fe9887997c1cbe51889869fa2f13cceca3b32dfed8ce5996a15e9

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