当前位置: 首页 > news >正文

做哪个网站比较有流量平台开发软件

做哪个网站比较有流量,平台开发软件,做网站郑州公司,建设网站的意义作用是什么意思学会基本的图像处理技术。‍ OpenCV 基础 实践#xff1a;使用 OpenCV 进行图像读取、显示和基本处理‍ 03 代码示例 1. 导入必要的库 import cv2import numpy as npimport matplotlib.pyplot as plt 2. 图像读取 # 读取图像image_path path_to_your_image.jpg # 替换…学会基本的图像处理技术。‍ OpenCV 基础 实践使用 OpenCV 进行图像读取、显示和基本处理‍ 03 代码示例 1. 导入必要的库 import cv2import numpy as npimport matplotlib.pyplot as plt 2. 图像读取 # 读取图像image_path path_to_your_image.jpg # 替换为你的图像路径image cv2.imread(image_path)# 检查图像是否成功读取if image is None: print(图像读取失败请检查路径是否正确。)else: print(图像读取成功) 3. 图像显示 # 使用 OpenCV 显示图像cv2.imshow(原图, image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示图像plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))plt.title(原图)plt.axis(off)plt.show() 4. 图像基本信息 # 获取图像的基本信息height, width, channels image.shapeprint(f图像高度: {height} 像素)print(f图像宽度: {width} 像素)print(f图像通道数: {channels}) 5. 图像灰度化​​​​​​​ # 将图像转换为灰度图像gray_image cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)# 显示灰度图像cv2.imshow(灰度图, gray_image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示灰度图像plt.imshow(gray_image, cmapgray)plt.title(灰度图)plt.axis(off)plt.show() 6. 图像裁剪​​​​​​​ # 裁剪图像cropped_image image[100:400, 100:400]# 显示裁剪后的图像cv2.imshow(裁剪图, cropped_image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示裁剪后的图像plt.imshow(cv2.cvtColor(cropped_image, cv2.COLOR_BGR2RGB))plt.title(裁剪图)plt.axis(off)plt.show() 7. 图像缩放​​​​​​​ # 缩放图像resized_image cv2.resize(image, (width // 2, height // 2))# 显示缩放后的图像cv2.imshow(缩放图, resized_image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示缩放后的图像plt.imshow(cv2.cvtColor(resized_image, cv2.COLOR_BGR2RGB))plt.title(缩放图)plt.axis(off)plt.show() 8. 图像旋转​​​​​​​ # 旋转图像center (width // 2, height // 2)angle 45scale 1.0rotation_matrix cv2.getRotationMatrix2D(center, angle, scale)rotated_image cv2.warpAffine(image, rotation_matrix, (width, height))# 显示旋转后的图像cv2.imshow(旋转图, rotated_image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示旋转后的图像plt.imshow(cv2.cvtColor(rotated_image, cv2.COLOR_BGR2RGB))plt.title(旋转图)plt.axis(off)plt.show() 9. 图像翻转​​​​​​​ # 翻转图像flipped_image cv2.flip(image, 1) # 1 表示水平翻转0 表示垂直翻转-1 表示水平和垂直翻转# 显示翻转后的图像cv2.imshow(翻转图, flipped_image)cv2.waitKey(0)cv2.destroyAllWindows()# 使用 Matplotlib 显示翻转后的图像plt.imshow(cv2.cvtColor(flipped_image, cv2.COLOR_BGR2RGB))plt.title(翻转图)plt.axis(off)plt.show() 10. 图像保存​​​​​​​ # 保存处理后的图像output_path processed_image.jpgcv2.imwrite(output_path, flipped_image)print(f处理后的图像已保存到 {output_path})04 实践​​​​​​​ import cv2import numpy as npimport matplotlib.pyplot as plt# 读取图像image_path path_to_your_image.jpg # 替换为你的图像路径image cv2.imread(image_path)# 检查图像是否成功读取if image is None: print(图像读取失败请检查路径是否正确。)else: print(图像读取成功) # 使用 OpenCV 显示图像 cv2.imshow(原图, image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示图像 plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) plt.title(原图) plt.axis(off) plt.show() # 获取图像的基本信息 height, width, channels image.shape print(f图像高度: {height} 像素) print(f图像宽度: {width} 像素) print(f图像通道数: {channels}) # 将图像转换为灰度图像 gray_image cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 显示灰度图像 cv2.imshow(灰度图, gray_image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示灰度图像 plt.imshow(gray_image, cmapgray) plt.title(灰度图) plt.axis(off) plt.show() # 裁剪图像 cropped_image image[100:400, 100:400] # 显示裁剪后的图像 cv2.imshow(裁剪图, cropped_image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示裁剪后的图像 plt.imshow(cv2.cvtColor(cropped_image, cv2.COLOR_BGR2RGB)) plt.title(裁剪图) plt.axis(off) plt.show() # 缩放图像 resized_image cv2.resize(image, (width // 2, height // 2)) # 显示缩放后的图像 cv2.imshow(缩放图, resized_image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示缩放后的图像 plt.imshow(cv2.cvtColor(resized_image, cv2.COLOR_BGR2RGB)) plt.title(缩放图) plt.axis(off) plt.show() # 旋转图像 center (width // 2, height // 2) angle 45 scale 1.0 rotation_matrix cv2.getRotationMatrix2D(center, angle, scale) rotated_image cv2.warpAffine(image, rotation_matrix, (width, height)) # 显示旋转后的图像 cv2.imshow(旋转图, rotated_image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示旋转后的图像 plt.imshow(cv2.cvtColor(rotated_image, cv2.COLOR_BGR2RGB)) plt.title(旋转图) plt.axis(off) plt.show() # 翻转图像 flipped_image cv2.flip(image, 1) # 1 表示水平翻转0 表示垂直翻转-1 表示水平和垂直翻转 # 显示翻转后的图像 cv2.imshow(翻转图, flipped_image) cv2.waitKey(0) cv2.destroyAllWindows() # 使用 Matplotlib 显示翻转后的图像 plt.imshow(cv2.cvtColor(flipped_image, cv2.COLOR_BGR2RGB)) plt.title(翻转图) plt.axis(off) plt.show() # 保存处理后的图像 output_path processed_image.jpg cv2.imwrite(output_path, flipped_image) print(f处理后的图像已保存到 {output_path})05 总结 通过今天的练习你应该已经学会了如何使用 OpenCV 进行基本的图像处理包括图像读取、显示、灰度化、裁剪、缩放、旋转和翻转 数据管道 学会安装和配置 Apache Airflow 使用 Airflow 构建一个简单的数据处理管道 调度和监控任务‍ 01 目标 学会安装和配置 Apache Airflow 使用 Airflow 构建一个简单的数据处理管道 调度和监控任务‍ 02 步骤 1. 安装 Apache Airflow 首先我们需要安装 Apache Airflow。可以使用 pip 来安装 pip install apache-airflow 2. 初始化 Airflow 初始化 Airflow 的数据库和配置文件 airflow db init 3. 启动 Airflow Web 服务器 启动 Airflow 的 Web 服务器这样我们可以在浏览器中监控和管理任务 airflow webserver --port 8080 4. 启动 Airflow Scheduler 启动 Airflow 的调度器它负责调度任务 airflow scheduler 5. 创建 DAG 文件 DAGDirected Acyclic Graph是 Airflow 中的核心概念表示一系列任务的依赖关系。我们将在 dags 目录下创建一个 Python 文件来定义我们的 DAG。 假设我们有一个简单的数据处理管道包括以下几个任务 从 CSV 文件中读取数据 清洗数据处理缺失值和重复行 按部门分组并计算每组的销售额均值 将结果保存到新的 CSV 文件 创建一个名为 simple_data_pipeline.py 的文件内容如下​​​​​​​ from airflow import DAGfrom airflow.operators.python_operator import PythonOperatorfrom datetime import datetime, timedeltaimport pandas as pdimport os# 定义默认参数default_args { owner: airflow, depends_on_past: False, start_date: datetime(2023, 1, 1), retries: 1, retry_delay: timedelta(minutes5),}# 创建 DAGdag DAG( simple_data_pipeline, default_argsdefault_args, description一个简单的数据处理管道, schedule_intervaltimedelta(days1),)# 定义任务函数def read_csv_file(): 从 CSV 文件中读取数据 file_path /path/to/sales_data.csv df pd.read_csv(file_path, encodingutf-8-sig) print(f原始数据集: \n{df.head()}) return dfdef clean_data(**context): 清洗数据处理缺失值和重复行 df context[ti].xcom_pull(task_idsread_csv_file) # 检查每列的缺失值数量 missing_values df.isnull().sum() print(f每列的缺失值数量: \n{missing_values}) # 删除含有缺失值的行 df_cleaned df.dropna() print(f删除缺失值后的数据集: \n{df_cleaned.head()}) # 检查重复行 duplicates df_cleaned.duplicated() print(f重复行: \n{duplicates}) # 删除重复行 df_no_duplicates df_cleaned.drop_duplicates() print(f删除重复行后的数据集: \n{df_no_duplicates.head()}) return df_no_duplicatesdef group_and_calculate_mean(**context): 按部门分组并计算每组的销售额均值 df context[ti].xcom_pull(task_idsclean_data) # 按 部门 列分组 grouped_by_department df.groupby(部门) # 计算每组的销售额均值 mean_sales_by_department grouped_by_department[总价].mean() print(f按 部门 列分组后每组的销售额均值: \n{mean_sales_by_department}) return mean_sales_by_departmentdef save_results(**context): 将结果保存到新的 CSV 文件 mean_sales_by_department context[ti].xcom_pull(task_idsgroup_and_calculate_mean) result_path /path/to/mean_sales_by_department.csv mean_sales_by_department.to_csv(result_path, encodingutf-8-sig) print(f结果已保存到 {result_path})# 定义任务read_csv_task PythonOperator( task_idread_csv_file, python_callableread_csv_file, dagdag,)clean_data_task PythonOperator( task_idclean_data, python_callableclean_data, provide_contextTrue, dagdag,)group_and_calculate_mean_task PythonOperator( task_idgroup_and_calculate_mean, python_callablegroup_and_calculate_mean, provide_contextTrue, dagdag,)save_results_task PythonOperator( task_idsave_results, python_callablesave_results, provide_contextTrue, dagdag,)# 设置任务依赖关系read_csv_task clean_data_task group_and_calculate_mean_task save_results_task 6. 配置 Airflow 确保 dags 目录在 Airflow 的配置文件中正确设置。通常情况下Airflow 会自动检测 dags 目录下的 DAG 文件。 7. 运行和监控任务 打开浏览器访问 http://localhost:8080登录 Airflow 的 Web 界面。 在 DAG 列表中找到 simple_data_pipeline点击进入详细页面。 点击 Trigger Dag 按钮手动触发任务或者等待调度器自动运行任务。 在任务详情页面中可以查看每个任务的运行状态和日志。‍ 03 总结 通过今天的实践你应该已经学会了如何使用 Apache Airflow 构建一个简单的数据处理管道。这个管道包括从 CSV 文件中读取数据、清洗数据、按部门分组计算销售额均值并将结果保存到新的 CSV 文件。
http://www.pierceye.com/news/878285/

相关文章:

  • 网站建设策划包括哪些内容展馆设计图
  • 网站建设中 翻译六安市 网站集约化建设
  • 全国卫生机构建设管理系统网站公司网站维护费用计哪个科目
  • 学做川菜最好的网站商标综合查询
  • 网站开发培训 价格哪些网站可以找到兼职做报表的
  • 网站建设功能分为几种北京自考网址
  • 购买网站域名怎么做会计分录广告机免费投放
  • 网上做网站赚钱深圳市无限空间工业设计有限公司
  • 商贸网站建设怎么查看wordpress版本
  • 电子商务网站建设哪本教材比较适合中等专业学校用网站建设yankt
  • 局域网网站建设需要什么条件企业建网站的目的
  • 高校专业建设网站桂林漓江竹筏
  • 自已做个网站怎么做网站网络的可用性
  • 深圳网站设计建设永州做网站
  • 怎么制作网站应用wordpress 淘宝客赚钱
  • 网站在政务新媒体建设方案打开手机网站速度慢
  • 网站备案表服务类网站模板
  • 个人网站维护费用淮安注册公司
  • 网站提交做海鱼的网站
  • 建设网站业务竞争大唯一做魅惑的网站
  • 建设学校网站的意义更换wordpress图标
  • 环保局网站如何做备案证明在线代理服务器网页版
  • 十佳网站武昌做网站哪家好
  • wordpress调用同分类最新文章seo营销网站的设计标准
  • 免费下载网站有哪些连云港网络公司排名
  • 如何迅速建企业网站毕设做网站需要什么技术准备
  • 可以做音基题的音乐网站公司网页设计怎么弄
  • 益阳营销型网站建设乌鲁木做兼职的网站
  • 如何建单位网站怎么让别人找你做网站
  • 青海建设厅职称网站建设小程序怎么挂失