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

微信网站打不开海南搜索引擎优化

微信网站打不开,海南搜索引擎优化,网站建设 英文,服务器做网站空间程序: 路径改成自己的,阈值可以修改也可以默认 #zhouzhichao #25年5月17日 #计算时频图中信号面积占检测框面积的比值import os import numpy as np import pandas as pd from PIL import Image# Define the path to the directory containing the lab…

程序:

路径改成自己的,阈值可以修改也可以默认

#zhouzhichao
#25年5月17日
#计算时频图中信号面积占检测框面积的比值import os
import numpy as np
import pandas as pd
from PIL import Image# Define the path to the directory containing the label txt files
label_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\微调原理\diff_snr\snr_dataset\label_txt'
img_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\微调原理\diff_snr\snr_dataset\6'
binary_output_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\像素面积比值\binary img'# Make sure the output directory exists
os.makedirs(binary_output_dir, exist_ok=True)# Initialize lists for storing the results for each class
ratios_0 = []
ratios_1 = []
ratios_2 = []
ratios_3 = []# Function to calculate the ratio of signal area to the bounding box area
def calculate_area_ratio(image_path, label_path, binary_output_dir):# Load the image and convert it to grayscaleimage = Image.open(image_path).convert('L')  # Convert to grayscale (L mode)image_array = np.array(image)# Read the label filewith open(label_path, 'r') as file:labels = file.readlines()for label in labels:# Parse the labellabel_data = label.strip().split()class_id = int(label_data[0])  # Class IDx_center = float(label_data[1])  # x center normalizedy_center = float(label_data[2])  # y center normalizedbox_width = float(label_data[3])  # box width normalizedbox_height = float(label_data[4])  # box height normalized# Convert the normalized values to pixel values based on image sizeimg_width, img_height = image.sizex_center_px = int(x_center * img_width)y_center_px = int(y_center * img_height)box_width_px = int(box_width * img_width)box_height_px = int(box_height * img_height)# Calculate the bounding box coordinatesx_min = max(x_center_px - box_width_px // 2, 0)y_min = max(y_center_px - box_height_px // 2, 0)x_max = min(x_center_px + box_width_px // 2, img_width)y_max = min(y_center_px + box_height_px // 2, img_height)# Extract the bounding box regionbbox_region = image_array[y_min:y_max, x_min:x_max]# Threshold the image (binary thresholding)binary_region = np.where(bbox_region > 128, 1, 0)  # 128 as threshold# Calculate the area of the signal inside the bounding box (sum of binary values)signal_area = np.sum(binary_region)# Calculate the area of the bounding boxbox_area = box_width_px * box_height_px# Save the binary image of the region to the output folderbinary_image = Image.fromarray(binary_region.astype(np.uint8) * 255)  # Convert to 0-255 scale for savingbinary_image.save(os.path.join(binary_output_dir, f'binary_{class_id}_{x_center_px}_{y_center_px}.png'))# Calculate the area ratioarea_ratio = signal_area / box_area if box_area > 0 else 0if class_id==0:ratios_0.append(area_ratio)if class_id==1:ratios_1.append(area_ratio)if class_id == 2:ratios_2.append(area_ratio)if class_id == 3:ratios_3.append(area_ratio)# Traverse all the label files and calculate area ratios
for label_file in os.listdir(label_dir):if label_file.endswith('.txt'):# Get corresponding image pathlabel_path = os.path.join(label_dir, label_file)image_name = label_file.replace('.txt', '.jpg')  # Assuming image is in .jpg formatimage_path = os.path.join(img_dir, image_name)# Calculate area ratios for the current label filecalculate_area_ratio(image_path, label_path, binary_output_dir)data = {'ratios_0': ratios_0,'ratios_1': ratios_1,'ratios_2': ratios_2,'ratios_3': ratios_3
}# 创建一个 DataFrame
df = pd.DataFrame(data)# 保存到 Excel 文件
file_path = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\像素面积比值\area_ratios.xlsx'
df.to_excel(file_path, index=False)
print()

程序依照的公式:

生成结果:

可用于绘制论文实验图:

http://www.dtcms.com/a/407478.html

相关文章:

  • 国产化(银河麒麟_海光CPU)消息中间件选型及安装
  • 宁波品牌网站推广优化公司章丘营销型网站设计公司
  • p6spy 打印完整sql
  • 【ARM】MDK-Functions界面设置
  • 沈阳市建设局网站首页网站的运行与维护
  • 昌宁县住房和城乡建设网站订阅号做流量 那些电影如何链接网站
  • 【LVS入门宝典】LVS调度算法轮询(RR)深度解析:从原理到实战的公平调度之道
  • udhcpc, udhcpd由 BusyBox编译出来就好
  • 前端 CORS 深度解析
  • HT81696 概述
  • PMP-项目管理-PMBOK第六版_中文版:引论
  • 上海网站建站建设自己做的网站在百度怎么发布
  • SpringBoot+QQ 邮箱邮件开发指南:环境配置、功能实现、异常处理一站式搞定
  • Linux 数据库 Mysql8 主从复制
  • 做网站的图片房产国内免费推广网站
  • 建设网站需要分析什么条件云南软件开发项目管理
  • OpenHands+cpolar:AI编程助手的远程调试新方案
  • 从 0 到 1 掌握 ESP32 RMT(新手友好版)
  • 做设计什么网站可以兼职网站管理与建设总结
  • 少样本学习学习论文分享:多模态性帮助单模态性
  • 深入MySQL底层2-SQL优化与数据库运维管理
  • 设计站网页制作的公司选时代创信
  • 国外服装网站石岩做网站哪家好
  • 超越单边控制:介绍新一代对话智能体评测基准τ2-Bench
  • Scala • basis
  • vi设计公司深圳企业网站排名怎么优化
  • 深度学习视角下的图像分类技术体系总结
  • mysql数据库最新版下载,安装
  • 记2831.找出最长等值子数组 练习理解
  • 优秀网站作品下载免费广告设计模板网站