Datafeame
1.新建
Data (np.random.randn(9))
2.合并
pd.merge(df1,all_color_hist,left_index=True,right_index=True)
3.删除列
merge1.drop([\'dss\'],axis=1)
4.索引元素
merge1.loc[i][0]
5.从数组获得值
all_color_proportion[0]=color_proportion
6.保存
pd.to_csv(\'../3_data/all_feature.csv\',header=None)
7.读取
pd.read_csv(\'../3_data/all_feature.csv\',header=None)
opencv
1.读取文中名的图片
def cv_imread(file_path):
cv_img=cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),-1)
return cv_img
2.matplotlib和opencv的RGB是反的
matplotlib显示顺序是R,G,B;opencv的顺序是B,G,R。
3.获得图片的高和宽
img_high=image.shape[0]
img_width=image.shape[1]
4.读取像素点
先行,后列。和x,y轴不同
image[img_high,img_width]
5.获取一部分区域数据
image=image[a:b,c:d]
6.将RGB转换为HSV
HSV=cv2.cvtColor(image,cv2.COLOR_BGR2HSV)
7.制作掩模
第一个变量中的元素在第二个和第三个元素之间就返回白,不然返回黑
mask=cv2.inRange(HSV,lower,upper)
8.获得直方图
hist_mask = cv2.calcHist([mask],[0],None,[2],[0,256])
保存txt
doc=open(\'../杜胜盛.txt\',\'w\',encoding=\'utf-8\')
print(filename[:-4],\',\',Ypred,file=doc)
print(filename,merge1.loc[i][0],file=doc)
doc.close()
继续阅读与本文标签相同的文章
企业ERP系统二次开发问题的探讨分析
-
运营专家详解“花呗分期”
2026-05-18栏目: 教程
-
谈一谈 iOS 的锁
2026-05-18栏目: 教程
-
《Android自定义控件开发入门与实战》| 每日读本书
2026-05-18栏目: 教程
-
除了吃月饼,中秋节还能干啥? | 9月12号栖夜读
2026-05-18栏目: 教程
-
图数据库爱好者的聚会在谈论什么?
2026-05-18栏目: 教程
