简体   繁体   English

NxN 矩阵的筛选描述符列表

[英]List of sift descriptors to an NxN matrix

I have a lot of sift descriptor from a dense-sift algorithm.我有很多来自密集筛选算法的筛选描述符。 Its an Array of N SIFT descriptor.它是一个 N SIFT 描述符数组。 One descriptor looks like this one:一个描述符看起来像这样:

[14.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 16.0, 0.0, ...]

y Goal is to transform the descriptors to an NxN Matrix so i can use them like an image feature input for an Machine Learning Struktur. y 目标是将描述符转换为 NxN 矩阵,以便我可以将它们用作机器学习结构的图像特征输入。 So in Short: I want to transform many 1d arrays to an 2d Array taking into account that the data points are split in the correct order.简而言之:考虑到数据点以正确的顺序拆分,我想将许多一维 arrays 转换为二维数组。

Is there a way to work with np.vstack or is there a other approach?有没有办法使用 np.vstack 还是有其他方法?

You can use stack and reshape and specify the desired axis like the following:您可以使用stackreshape并指定所需的轴,如下所示:

import numpy as np

arr1 = np.ones((1, 128))
arr1 = arr1.reshape((4,4,8))

arr2 = np.ones((1, 128))
arr2 = arr2.reshape((4,4,8))


print(np.stack((arr1, arr2), axis=3).shape)
# (4, 4, 8, 2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM