Skip to main content

Invariant patch distances and clustering

Project description

This package includes methods for clustering patches and reconstructing images using invariant patch distances. The package is build upon the CUDA C++ project: invariant_patch_distances. The package has the following dependencies: an NVIDIA graphics card of compute capability 3.x or higher, CUDA 10.0 and CMake 3.10.

Example

The following example shows how to cluster patches and reconstruct an image using these clusters.

import patchdistances as pd

# Load image as Float32 numpy array. It can either be gray-scale or rgb.
img = load_image()

// Initialize the distance class.
// Alternatively: similarity_inv_dist.
aid = pd.affine_inv_dist()

// Greedy-k-center clustering of the image patches using the distance.
labels, indices_of_labels = aid.greedy_k_center(
    image=img,
    patch_shape=(7,7),
    clusters=20,
    first_patch_idx=0,
    solver=pd.solver_t.procrustes,
    func_family=pd.func_t.superlevelsets,
    use_imed=False,
    interpolation=pd.inter_t.bicubic,
)

// Reconstruct the image using the previously clustered patches.
// Alternatively: reconstruct_w_translation.
reconstructed_image, nearest_neighbor_labeling = aid.reconstruct(
    image=img,
    labels=labels,
    rec_type=pd.rec_t.Median,
    solver=pd.solver_t.procrustes,
    func_family=pd.func_t.superlevelsets,
    use_imed=False,
    interpolation=pd.inter_t.bicubic,
)

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

patchdistances-1.0.tar.gz (553.3 kB view details)

Uploaded Source

File details

Details for the file patchdistances-1.0.tar.gz.

File metadata

  • Download URL: patchdistances-1.0.tar.gz
  • Upload date:
  • Size: 553.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for patchdistances-1.0.tar.gz
Algorithm Hash digest
SHA256 6b3a43570dfcc53e41fa5045954c2a43f5665e94eb792ae52d8fccab3f7446b8
MD5 28f0de090210423ae0b3bcac83dc854b
BLAKE2b-256 7d690182a510562ad7d81dac0711fe9b24847bc52513f435411193373f98d902

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