Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 将多个类中的特征平均为单个特征向量类_Image Processing_Feature Extraction_Template Matching_Centroid_Image Classification - Fatal编程技术网

Image processing 将多个类中的特征平均为单个特征向量类

Image processing 将多个类中的特征平均为单个特征向量类,image-processing,feature-extraction,template-matching,centroid,image-classification,Image Processing,Feature Extraction,Template Matching,Centroid,Image Classification,我从20类200幅图像中提取特征。代码返回特征提取(数据)和类标签(标签),如下所示。我想找到每类特征的平均值,并使用它为每类图像创建一个模板,以使用距离度量或KNN预测新的输入图像 data = [] label = [] df = pd.DataFrame() df2 = pd.DataFrame() df3 = pd.DataFrame() for dir1 in os.listdir(img_folder): for file in os.listdir(os.path.joi

我从20类200幅图像中提取特征。代码返回特征提取(数据)和类标签(标签),如下所示。我想找到每类特征的平均值,并使用它为每类图像创建一个模板,以使用距离度量或KNN预测新的输入图像

data = []
label = []

df = pd.DataFrame()
df2 = pd.DataFrame()
df3 = pd.DataFrame()
for dir1 in os.listdir(img_folder):
    for file in os.listdir(os.path.join(img_folder, dir1)):
        filename = os.path.join(img_folder, dir1,  file)
        # read image
        
        img = cv2.imread(filename)
        img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
                               
        # = FeatureExtractor()
        edges=cv2.Canny(image_result, 200, 300)
        hog_feature, hog_image = hog(edges, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(2, 2), block_norm= 'L2',visualize=True)

        image_label = os.path.splitext(os.path.basename(dir1))[0]

        # append descriptor and label to train/test data, labels
        data.append(hog_feature)
        
        label.append(image_label)
df = pd.DataFrame(data)
df.to_csv("data/images/Features1.csv")
df2 = pd.DataFrame(label)
df2.to_csv("data/images/label1.csv")

dataset_features=pd.concat([df2, df], axis=1) 
df3 = pd.DataFrame(dataset_features)
df3.to_csv("data/images/AllFeatures.csv")

# return data and label
return data, label