python图像上的滑动窗口

问题描述 投票:0回答:1

我想将此matlab代码转换为python:图片= [];图像中的foreach图像:功能= [];windows = extractWindows(image,size =(30,30),stride =(30,30));Windows中的foreach窗口:featureVector = extractFeatures(window);features.append(featureVector);saveAsCSV('image_name_features.txt',features);

python window sliding
1个回答
0
投票
def sliding_window(image, stepSize, windowSize):
  for y in range(0, image.shape[0], stepSize):
    for x in range(0, image.shape[1], stepSize):
      yield (x, y, image[y:y + windowSize[1], x:x + windowSize[0]])

def extractFeatures(window):
  # fast? sift? orb? or something?
  return features

images = []
for image in images:
  features = []
  windows = sliding_window(image, 30, (30, 30))
  for window in windows:
    featureVector = extractFeatures(window)
    features.append(featureVector)

  numpy.savetxt('image_name_features.txt', feautres, delimiter=",")
© www.soinside.com 2019 - 2024. All rights reserved.