【问题标题】:SIFT Input to ANN对 ANN 的 SIFT 输入
【发布时间】:2017-07-10 14:39:12
【问题描述】:

我正在尝试使用人工神经网络对图像进行分类,我想尝试的方法是:

  1. 获取特征描述符(目前使用 SIFT)
  2. 使用神经网络进行分类

我为此使用 OpenCV3 和 Python。

我对机器学习比较陌生,我有以下问题 -

我分析的每张图像都有不同数量的“关键点”,因此二维“描述符”数组的维度也不同。我如何决定我的 ANN 的输入。例如,对于一个样本图像,描述符形状为 (12211, 128),所以我是否将这个数组展平并将其用作输入,在这种情况下,我必须担心每个图像的输入大小不同,或者我是否计算其他东西输入?

【问题讨论】:

  • 对于人工神经网络,您通常需要固定大小的输入。

标签: python opencv neural-network classification sift


【解决方案1】:

我不确定这是否是一个确切的解决方案,但这对我有用。主要思路如下:

  • 将图像划分为 MxN 网格。
  • 为每个子图像获取一组特征点。
  • 连接所有子图像的结果以获得整个图像的特征向量。

支持代码大致如下(函数“pre_process_image”):

def tiles(arr, nrows, ncols):
    """
    If arr is a 2D array, the returned list contains nrowsXncols numpy arrays
    with each array preserving the "physical" layout of arr.

    When the array shape (rows, cols) are not divisible by (nrows, ncols) then
    some of the array dimensions can change according to numpy.array_split.

    """
    rows, cols, channel = arr.shape
    col_arr = np.array_split(range(cols), ncols)
    row_arr = np.array_split(range(rows), nrows)
    return [arr[r[0]: r[-1]+1, c[0]: c[-1]+1]
                     for r, c in product(row_arr, col_arr)]

def pre_process_images(data, dimensions=(28, 28)):
    images = data['image']
    features = []
    count = 1
    nrows = dimensions[0]
    ncols = dimensions[1]
    sift = cv2.xfeatures2d.SIFT_create(1)
    for arr in images:
        image_feature = []
        cut_image = tiles(arr, nrows, ncols)
        for small_image in cut_image:
            (kps, descs) = sift.detectAndCompute(im, None)
            image_feature.append(descs.flatten())
        features.append(image_feature)
        print count
        count += 1

    data['sift_features'] = features
    return data

但是,这非常很慢。我现在正在研究一种使用 PCA 优化选择功能的方法。

【讨论】:

    【解决方案2】:

    如果在获取特征提取器之前对每个图像应用归一化会很好。

    【讨论】:

      猜你喜欢
      • 2020-11-18
      • 2013-11-10
      • 2013-12-07
      • 2013-11-04
      • 2023-04-10
      • 2020-09-10
      • 2012-02-01
      • 1970-01-01
      • 2012-02-06
      相关资源
      最近更新 更多