不变分片距离与聚类
patchdistances的Python项目详细描述
这个软件包包含了使用不变的面片距离来聚类和重建图像的方法。 包是基于CUDA C++项目构建的:invariant_patch_distances。 该软件包具有以下依赖关系:计算能力为3.x或更高的NVIDIA显卡, CUDA 10.0和CMake 3.10。在
示例
下面的示例演示如何使用这些簇对面片进行聚类并重建图像。在
importpatchdistancesaspd# Load image as Float32 numpy array. It can either be gray-scale or rgb.img=load_image()//Initializethedistanceclass.//Alternatively:similarity_inv_dist.aid=pd.affine_inv_dist()//Greedy-k-centerclusteringoftheimagepatchesusingthedistance.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,)//Reconstructtheimageusingthepreviouslyclusteredpatches.//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,)
- 项目
标签: