vsi package

Subpackages

Submodules

vsi.iglob module

Filename globbing utility with optional case sensitive override.

vsi.iglob._unicode

alias of str

vsi.iglob.glob(pathname, case=None)[source]

Return a list of paths matching a pathname pattern.

Parameters:

pathname (str) – The Path Name

Returns:

A list of paths matching a pathname pattern

Return type:

list

The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by ‘*’ and ‘?’ patterns.

Set case to true to force case sensitive, false to force case insensitive or None(default) to run glob natively

vsi.iglob.iglob(pathname, case=None)[source]

Return an iterator which yields the paths matching a pathname pattern.

Parameters:

pathname (str) – The Path Name

The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by ‘*’ and ‘?’ patterns.

Set case to true to force case sensitive, false to force case insensitive or None(default) to run glob natively

vsi.image module

vsi.image.find_template_offset(template: numpy.floating, image: numpy.floating, debug_dir: str | None = None) Tuple[int, int, float][source]

Uses 2-D normalized cross correlation to find the offset of the upper right corners of the template and image

Parameters:
  • template (numpy.ndarray) – N-D array of template or filter you are using for cross-correlation. Must be less or equal dimensions to image. Length of each dimension must be less than length of image. Array should be floating point numbers.

  • image (numpy.ndarray) – Image array should be floating point numbers.

  • debug_dir (str) – Optional directory to write debugging visualization images to.

Returns:

  • int – y offset in pixels

  • int – x offset in pixels

  • float – The quality of the fit (scale of -1 to 1), where 1 is a perfect 100% match, and -1 is a perfect negative match. 0 is no match

vsi.image.find_template_offset_centered(template_image: numpy.floating, image: numpy.floating, template_center: Tuple[int, int], image_center: Tuple[int, int], template_radius: int | Tuple[int, int] = 50, image_radius: int | Tuple[int, int] = 200, adjust_template: Callable[[numpy.ndarray, int, int, int, int], Tuple[int, int, int, int]] | None = None, debug_dir: str | None = None)[source]

Uses 2-D normalized cross correlation to find the offset of a point of interest between in two images. This is a convenient form of the find_template_offset() function, that will handle boundary conditions and do the math to tell you the offset of specific point of interest at the centers

Parameters:
  • template_image (numpy.ndarray) – The image containing the template patch

  • image (numpy.ndarray) – Image array should be floating point numbers.

  • template_center (tuple) – The location of the POI in the template image, (y,x) coordinate

  • image_center (tuple) – The location of the POI in the image, (y,x) coordinate

  • template_radius (int or tuple, optional) – The radius around the template used for the cross correlation. Can be a single number (in which case the same number is used in both the x and y direction), or a tuple of two numbers (y radius, x radius). E.g.: 50 will create a patch 101 by 101, unless it is too close to the edge in which case it will be smaller. Default is 50, and must be smaller than image_radius.

  • image_radius (int or tuple, optional) – The radius around the image. Default: 200

  • adjust_template (Callable) – Function to call to warp the template image before correlation.

  • debug_dir (str) – Optional directory to write debugging visualization images to.

Returns:

  • int – y offset in pixels

  • int – x offset in pixels

  • float – The quality of the fit (scale of -1 to 1), where 1 is a perfect 100% match, and -1 is a perfect negative match. 0 is no match

vsi.image.normalized_cross_correlation_2d(template: numpy.floating.~T, image: numpy.floating.~T, mode: str = 'full')[source]

Computes the 2-D normalized cross correlation (Aka: normxcorr2) between the template and image.

Parameters:
  • template (numpy.ndarray) – N-D array of template or filter you are using for cross-correlation. Length of each dimension must be less than equal to the corresponding dimension of the image. Array should be floating point numbers.

  • image (numpy.ndarray) – Image array should be floating point numbers.

  • mode (str, optional) –

    • full (Default): The output of fftconvolve is the full discrete linear convolution of the inputs. Output size will be image size + 1/2 template size in each dimension.

    • valid: The output consists only of those elements that do not rely on the zero-padding.

    • same: The output is the same size as image, centered with respect to the “full” output.

Returns:

N-D array of same dimensions as image. Size depends on mode parameter.

Return type:

numpy.ndarray

vsi.image.visualize_cross_correlation(debug_dir: str, template: numpy.floating, image: numpy.floating, xc: numpy.floating, peak: Tuple[int, int], peak_magnitude: float, offset: Tuple[int, int]) None[source]

Save out visualization images to the provided debugging directory.

Parameters:
  • debug_dir (str) – Debugging directory to write visualization images to.

  • template (numpy.ndarray) – N-D array of template or filter used for cross-correlation. Array should be floating point numbers between 0 and 1.

  • image (numpy.ndarray) – Image array should be floating point numbers between 0 and 1.

  • xc (numpy.ndarray) – The 2-D normalized cross correlation of the template and image.

  • peak (tuple) – The (y, x) pixel coordinate of the peak of the correlation surface.

  • peak_magnitude (float) – The scalar magnitude of the correlation peak.

  • offset (tuple) – The (y, x) offset to translate the image by to match the image.

Return type:

None

vsi.yarp module

vsi.yarp.yarp(doc, prefix='')[source]

Module contents