gpt4 book ai didi

python - python图像上的滑动窗口

转载 作者:行者123 更新时间:2023-12-05 01:37:25 25 4
gpt4 key购买 nike

我想将这段 matlab 代码转换为 python:

images = []; 
foreach image in images:
features = [];
windows = extractWindows(image,size=(30,30),stride=(30,30));
foreach window in windows:
featureVector = extractFeatures(window);
features.append(featureVector);
saveAsCSV('image_name_features.txt',features);

最佳答案

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=",")

关于python - python图像上的滑动窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61051120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com